Minor improvement
[u/mrichter/AliRoot.git] / RICH / RichConfig.C
1 #include <TPDGCode.h>
2
3 class RichConfig : public TGMainFrame
4 {
5 RQ_OBJECT()
6 public:
7           RichConfig(const char*sFileName);
8          ~RichConfig()                    {Info("ctor","");Cleanup();}
9          
10   enum EVersOpts  {kNo=101,kVer0,kVer1,kVer2,kTest, kDeclust=301,kSagita,kFeedback,kSecRad,kQe0=400,kQeNorm,kOptics};
11   enum EGenTypes  {kGunZ=1,kGun1,kGun7,kBox,kHijing,kHijingPara,kPythia,kRichLib,kNotUsed=999};
12   
13   enum EDetectors {kPIPE=1,kITS,kTPC,kTRD,kTOF,kFRAME,kMAG,kCRT,kHALL,kPHOS,kSTART,kFMD,kABSO,kPMD,kDIPO,kEMCAL,kVZERO,kMUON,kZDC,kSHILD};
14   enum EProcesses {kDCAY=1,kPAIR,kCOMP,kPHOT,kPFIS,kDRAY,kANNI,kBREM,kMUNU,kCKOV,kHADR,kLOSS,kMULS,kRAYL,kALL};
15   enum EBatchFlags{kPrim=555,kTransport,kAll,kOnly,kRawDdl,kRawDate,kRawRoot,kVertex,kTrack,kHlt,kEsd};
16   enum EMagField  {kFld0,kFld2,kFld4,kFld5,kFld_2,kFld_4,kFld_5};
17   
18   Float_t Eta2Theta      (Float_t arg)  const{return (180./TMath::Pi())*2.*TMath::ATan(TMath::Exp(-arg));}
19   
20   void GuiRich (TGHorizontalFrame *pMainF);  void WriteRich (FILE *pF);  void RichSlot   (Int_t ver);
21   void GuiPhys (TGHorizontalFrame *pMainF);  void WritePhys (FILE *pF);  void PhysAddSlot(Int_t id); void PhysRemSlot(Int_t id);
22   void GuiGen  (TGCompositeFrame  *pMainF);  void WriteGen  (FILE *pF);  void GenAddSlot (Int_t id); void GenRemSlot (Int_t id);
23   void GuiDet  (TGHorizontalFrame *pMainF);  void WriteDet  (FILE *pF);  void DetAddSlot (Int_t id); void DetRemSlot (Int_t id);
24   void GuiBatch(TGHorizontalFrame *pMainF);  void WriteBatch(        );  void SlotBatch  (Int_t id);
25   
26   void    WriteConfig();
27   void    ExitSlot();
28      
29   TGButtonGroup *fVerBG,*fOptBG,*fQeBG; //Rich widgets  
30   TGButtonGroup *fMagBG;                //mag field widgets   
31   TGButton      *fDecayerB;             //external decayer widgets
32   
33   TGComboBox        *fGenPidCO,*fGenPminCO,*fGenPmaxCO,*fGenChamCO,*fGenNprimCO; //generator widgets combos
34   TGCompositeFrame  *fGenF;                                                     //generator widgets frames     
35   TGButtonGroup     *fGenBG;                                                    //generator widgets
36   
37   TGButtonGroup *fDetBG,*fProcBG;                                      //detectors and processes widgets
38   TGButtonGroup *fSimBG,*fSDigBG,*fDigBG,*fRawBG,*fClusBG,*fRecoBG;    //batch control widgets
39
40    char         *fFileName;
41 };//class RichConfig
42 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
43 RichConfig::RichConfig(const char *sFileName):TGMainFrame(gClient->GetRoot(),700,400)
44 {
45   fFileName=sFileName;
46
47   AddFrame(pMainF=new TGHorizontalFrame(this,100,200)); //main horizontal frame
48   
49   GuiRich (pMainF);
50   GuiGen  (pMainF);   
51   GuiDet  (pMainF);
52   GuiPhys (pMainF);
53   GuiBatch(pMainF);  
54   
55 //File    
56   AddFrame(pFileHF=new TGHorizontalFrame(this,100,200));
57   pFileHF->AddFrame(pCrtTB=new TGTextButton(pFileHF,"Create"));
58   pCrtTB->Connect("Clicked()","RichConfig",this,"ExitSlot()");                                 
59   pFileHF->AddFrame(new TGLabel(pFileHF,Form(" config file as %s",fFileName)));  
60   
61   MapSubwindows();   
62   Resize(GetDefaultSize());
63   SetWindowName("Create AliROOT scripts");
64   MapWindow(); 
65 }//ctor
66 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67 void RichConfig::GuiRich(TGHorizontalFrame *pMainHF)
68 {
69   pMainHF->AddFrame(pLeftVF=new TGVerticalFrame(pMainHF,100,200));  
70   pLeftVF->AddFrame(pRichGF=new TGGroupFrame(pLeftVF,"RICH"));
71   pRichGF->AddFrame(fVerBG=new TGButtonGroup(pRichGF,""));  fVerBG->Connect("Pressed(Int_t)" ,"RichConfig",this,"RichVerSlot(Int_t)");
72     new TGRadioButton(fVerBG,   "No"         ,kNo       ));   
73     new TGRadioButton(fVerBG,   "ver0"       ,kVer0     ));
74     new TGRadioButton(fVerBG,   "ver1"       ,kVer1     ));  fVerBG->SetButton(kVer1);
75     new TGRadioButton(fVerBG,   "ver2"       ,kVer2     ));
76   pRichGF->AddFrame(fOptBG=new TGButtonGroup(pRichGF,""));  fOptBG->Connect("Pressed(Int_t)" ,"RichConfig",this,"RichVerSlot(Int_t)");
77     new TGCheckButton(fOptBG,"Test beam position?"  ,kTest);       
78     new TGCheckButton(fOptBG,"Second radiator?"     ,kSecRad);       
79     new TGCheckButton(fOptBG,"Decluster?"           ,kDeclust);      fOptBG->SetButton(kDeclust);
80     new TGCheckButton(fOptBG,"Wire sagita?"         ,kSagita);       fOptBG->SetButton(kSagita);
81     new TGCheckButton(fOptBG,"Feedbacks?"           ,kFeedback);     fOptBG->SetButton(kFeedback); 
82     new TGCheckButton(fOptBG,"Plot optics?"         ,kOptics);     
83   pRichGF->AddFrame(fQeBG=new TGButtonGroup(pRichGF,""));
84     new TGRadioButton(fQeBG,"QE=0"                 ,kQe0);       
85     new TGRadioButton(fQeBG,"QE normal"            ,kQeNorm);       fQeBG->SetButton(kQeNorm);
86   pLeftVF->AddFrame(fDecayerB=new TGCheckButton(pLeftVF,"Puthia decayer On/Off"));  fDecayerB->SetState(kButtonDown);
87   pLeftVF->AddFrame(fMagBG=new TGButtonGroup(pLeftVF,"Mag field")); 
88     new TGRadioButton(fMagBG,   "0.5 T"      ,kFld5   ));
89     new TGRadioButton(fMagBG,   "0.4 T"      ,kFld4   ));
90     new TGRadioButton(fMagBG,   "0.2 T"      ,kFld2   ));  fMagBG->SetButton(kFld2);
91     new TGRadioButton(fMagBG,   "0 T"        ,kFld0   ));   
92     new TGRadioButton(fMagBG,   "-0.2 T"     ,kFld_2  ));
93     new TGRadioButton(fMagBG,   "-0.4 T"     ,kFld_4  ));
94     new TGRadioButton(fMagBG,   "-0.5 T"     ,kFld_5  ));
95 }//Rich()
96 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
97 void RichConfig::RichVerSlot(Int_t ver)  
98 {
99   if(ver==kTest)    {fMagBG->SetButton(kFld0); fGenBG->SetButton(kGunZ); }
100
101 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
102 void RichConfig::WriteRich(FILE *pF)
103 {
104   if(!fVerBG->GetButton(kNo)->GetState()){
105     TString title;
106     if( fOptBG->GetButton(kSecRad)->GetState())             title+=" Radiator2 ";
107     if(!fOptBG->GetButton(kSagita)->GetState())             fprintf(pF,"  AliRICHParam::fgIsWireSagita=kFALSE;\n");
108     if( fOptBG->GetButton(kTest)  ->GetState())             title+=" TestBeam ";
109     if( fOptBG->GetButton(kOptics)->GetState())             title+=" ShowOptics ";
110     if(title.Length()==0) title="Default";
111     
112     if     (fVerBG->GetButton(kVer0)->GetState())           fprintf(pF,"  new AliRICHv0(\"Gel %s\");\n\n",title.Data());    
113     else if(fVerBG->GetButton(kVer1)->GetState())           fprintf(pF,"  new AliRICHv1(\"RICH\",\"%s\");\n\n",title.Data());   
114     else if(fVerBG->GetButton(kVer2)->GetState())           fprintf(pF,"  new AliRICHv2(\"Tic %s\");\n\n",title.Data());   
115   }
116 }
117 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
118 void RichConfig::GuiPhys(TGHorizontalFrame *pMainHF)
119 {
120   pMainHF->AddFrame(fProcBG=new TGButtonGroup(pMainHF,"Procs"));
121   fProcBG->Connect("Pressed(Int_t)" ,"RichConfig",this,"PhysAddSlot(Int_t)");
122   fProcBG->Connect("Released(Int_t)","RichConfig",this,"PhysRemSlot(Int_t)");
123     new TGCheckButton(fProcBG,"ALL  ON/OFF"                 ,kALL)) ;
124     new TGCheckButton(fProcBG,"DCAY Decay"                  ,kDCAY));  fProcBG->SetButton(kDCAY);       
125     new TGCheckButton(fProcBG,"PAIR Pair production"        ,kPAIR));  fProcBG->SetButton(kPAIR);       
126     new TGCheckButton(fProcBG,"COMP Compton"                ,kCOMP));  fProcBG->SetButton(kCOMP);
127     new TGCheckButton(fProcBG,"PHOT"                        ,kPHOT));  fProcBG->SetButton(kPHOT);
128     new TGCheckButton(fProcBG,"PFIS Photofission"           ,kPFIS));  
129     new TGCheckButton(fProcBG,"DRAY Delta electrons"        ,kDRAY));  
130     new TGCheckButton(fProcBG,"ANNI Annihilation"           ,kANNI));  fProcBG->SetButton(kANNI);       
131     new TGCheckButton(fProcBG,"BREM Bremstraslung"          ,kBREM));  fProcBG->SetButton(kBREM);       
132     new TGCheckButton(fProcBG,"MUNU Muon-Nuclear"           ,kMUNU));  fProcBG->SetButton(kMUNU);       
133     new TGCheckButton(fProcBG,"CKOV Cerenkovs"              ,kCKOV));  fProcBG->SetButton(kCKOV);       
134     new TGCheckButton(fProcBG,"HADR Hadronic interactions " ,kHADR));  fProcBG->SetButton(kHADR);       
135     new TGCheckButton(fProcBG,"LOSS Energy losses"          ,kLOSS));  fProcBG->SetButton(kLOSS);       
136     new TGCheckButton(fProcBG,"MULS Multiple scattering"    ,kMULS));  fProcBG->SetButton(kMULS);       
137     new TGCheckButton(fProcBG,"RAYL Rayleigh scattering"    ,kRAYL));  fProcBG->SetButton(kRAYL);       
138 }
139 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
140 void RichConfig::PhysAddSlot(Int_t id)
141 {//slot is invoked when any of physics check button is pressed
142   if(id==kALL)  //if the pressed check button is kALL then switch on all the buttons 
143     for(int i=1;i<=fProcBG->GetCount();i++) 
144       fProcBG->SetButton(i,kButtonDown);
145 }
146 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
147 void  RichConfig::PhysRemSlot(Int_t id)
148 {//slot is invoked when any of physics check button is released
149   if(id==kALL) //if the released check button is kALL then switch off all the buttons 
150     for(int i=1;i<=fProcBG->GetCount();i++) 
151       fProcBG->SetButton(i,kButtonUp);
152 }
153 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
154 void RichConfig::WritePhys(FILE *pF)
155 {
156   if(fProcBG->GetButton(kDCAY)->GetState()) fprintf(pF,"  gMC->SetProcess(\"DCAY\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"DCAY\",0);  ");
157   if(fProcBG->GetButton(kPAIR)->GetState()) fprintf(pF,"  gMC->SetProcess(\"PAIR\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"PAIR\",0);  ");
158   if(fProcBG->GetButton(kCOMP)->GetState()) fprintf(pF,"  gMC->SetProcess(\"COMP\",1);\n");else fprintf(pF,"  gMC->SetProcess(\"COMP\",0);\n");
159   if(fProcBG->GetButton(kPHOT)->GetState()) fprintf(pF,"  gMC->SetProcess(\"PHOT\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"PHOT\",0);  ");
160   if(fProcBG->GetButton(kPFIS)->GetState()) fprintf(pF,"  gMC->SetProcess(\"PFIS\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"PFIS\",0);  ");
161   if(fProcBG->GetButton(kDRAY)->GetState()) fprintf(pF,"  gMC->SetProcess(\"DRAY\",1);\n");else fprintf(pF,"  gMC->SetProcess(\"DRAY\",0);\n");
162   if(fProcBG->GetButton(kANNI)->GetState()) fprintf(pF,"  gMC->SetProcess(\"ANNI\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"ANNI\",0);  ");
163   if(fProcBG->GetButton(kBREM)->GetState()) fprintf(pF,"  gMC->SetProcess(\"BREM\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"BREM\",0);  ");
164   if(fProcBG->GetButton(kMUNU)->GetState()) fprintf(pF,"  gMC->SetProcess(\"MUNU\",1);\n");else fprintf(pF,"  gMC->SetProcess(\"MUNU\",0);\n");
165   if(fProcBG->GetButton(kCKOV)->GetState()) fprintf(pF,"  gMC->SetProcess(\"CKOV\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"CKOV\",0);  ");
166   if(fProcBG->GetButton(kHADR)->GetState()) fprintf(pF,"  gMC->SetProcess(\"HADR\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"HADR\",0);  ");
167   if(fProcBG->GetButton(kLOSS)->GetState()) fprintf(pF,"  gMC->SetProcess(\"LOSS\",2);\n");else fprintf(pF,"  gMC->SetProcess(\"LOSS\",0);\n");
168   if(fProcBG->GetButton(kMULS)->GetState()) fprintf(pF,"  gMC->SetProcess(\"MULS\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"MULS\",0);  ");
169   if(fProcBG->GetButton(kRAYL)->GetState()) fprintf(pF,"  gMC->SetProcess(\"RAYL\",1);\n");else fprintf(pF,"  gMC->SetProcess(\"RAYL\",0);\n");
170   
171   fprintf(pF,"\n");  
172   fprintf(pF,"  gMC->SetCut(\"CUTGAM\",0.001);  "); fprintf(pF,"  gMC->SetCut(\"CUTELE\",0.001);  "); fprintf(pF,"  gMC->SetCut(\"CUTNEU\",0.001);\n"); 
173   fprintf(pF,"  gMC->SetCut(\"CUTHAD\",0.001);  "); fprintf(pF,"  gMC->SetCut(\"CUTMUO\",0.001);  "); fprintf(pF,"  gMC->SetCut(\"BCUTE\" ,0.001);\n");
174   fprintf(pF,"  gMC->SetCut(\"BCUTM\" ,0.001);  "); fprintf(pF,"  gMC->SetCut(\"DCUTE\" ,0.001);  "); fprintf(pF,"  gMC->SetCut(\"DCUTM\" ,0.001);\n"); 
175   fprintf(pF,"  gMC->SetCut(\"PPCUTM\",0.001);  "); fprintf(pF,"  gMC->SetCut(\"TOFMAX\",1e10);\n\n"); 
176 }//WritePhys()
177 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
178 void RichConfig::GuiGen(TGCompositeFrame *pMainF)
179 {//generator configurator implemented as group of radio buttons
180   pMainF->AddFrame(fGenF=new TGVerticalFrame(pMainF));//add generator vertical frame to horizontal main frame
181   fGenF->AddFrame(fGenBG=new TGButtonGroup(fGenF,"Gene"));//add type button group to vertical generator frame
182   fGenBG->Connect("Pressed(Int_t)","RichConfig",this,"GenAddSlot(Int_t)"); fGenBG->Connect("Released(Int_t)","RichConfig",this,"GenRemSlot(Int_t)");
183     new TGCheckButton(fGenBG,"gun along z"           ,kGunZ);
184     new TGCheckButton(fGenBG,"gun to 1 chamber"      ,kGun1);
185     new TGCheckButton(fGenBG,"gun to 7 chambers"     ,kGun7);
186     new TGCheckButton(fGenBG,"box RICH phase space"  ,kBox );  
187     new TGCheckButton(fGenBG,"HIJING"                ,kHijing);
188     new TGCheckButton(fGenBG,"HIJING para"           ,kHijingPara);
189     new TGCheckButton(fGenBG,"Pythia"                ,kPythia);
190     new TGCheckButton(fGenBG,"RICH lib"              ,kRichLib);
191 //N prims for box and Hijing para    
192   fGenF->AddFrame(fGenNprimCO=new TGComboBox(fGenF,100)); //add N prims combo to generator vertical frame
193   fGenNprimCO->AddEntry("not used"    ,kNotUsed);
194   fGenNprimCO->AddEntry("N prim=1"    ,1);
195   fGenNprimCO->AddEntry("N prim=2"    ,2);
196   fGenNprimCO->AddEntry("N prim=5"    ,5);
197   fGenNprimCO->AddEntry("N prim=100"  ,100);
198   fGenNprimCO->AddEntry("N prim=500"  ,500);
199   fGenNprimCO->AddEntry("N prim=1000" ,1000);
200   fGenNprimCO->AddEntry("N prim=10000",10000);
201   fGenNprimCO->AddEntry("N prim=80000",80000);  fGenNprimCO->Resize(160,20);   fGenNprimCO->Select(kNotUsed);
202 //PID    
203   fGenF->AddFrame(fGenPidCO=new TGComboBox(fGenF,100)); //add pid combo to generator vertical frame
204   fGenPidCO->AddEntry("not used"   ,kNotUsed);
205   fGenPidCO->AddEntry("electron"   ,kElectron);
206   fGenPidCO->AddEntry("positron"   ,kPositron);
207   fGenPidCO->AddEntry("pion +"     ,kPiPlus);
208   fGenPidCO->AddEntry("pion -"     ,kPiMinus);
209   fGenPidCO->AddEntry("kaon +"     ,kKPlus);
210   fGenPidCO->AddEntry("kaon -"     ,kKMinus);
211   fGenPidCO->AddEntry("kaon 0"     ,kK0Short);    
212   fGenPidCO->AddEntry("proton"     ,kProton);
213   fGenPidCO->AddEntry("antiproton" ,kProtonBar);
214   fGenPidCO->AddEntry("lambda"     ,kLambda0);
215   fGenPidCO->AddEntry("antilambda" ,kLambda0Bar);  fGenPidCO->Resize(160,20); fGenPidCO->Select(kNotUsed);
216 //Pmin  
217   fGenF->AddFrame(fGenPminCO=new TGComboBox(fGenF,100)); //add Pmin combo to generator vertical frame  
218   fGenPminCO->AddEntry("not used",kNotUsed);
219   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);
220 //Pmax  
221   fGenF->AddFrame(fGenPmaxCO=new TGComboBox(fGenF,100)); //add Pmax combo to generator vertical frame
222   fGenPmaxCO->AddEntry("not used",kNotUsed);
223   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);
224 //Chamber number  
225   fGenF->AddFrame(fGenChamCO=new TGComboBox(fGenF,100)); //add chamber number combo to generator vertical frame
226   fGenChamCO->AddEntry("not used",kNotUsed);
227   for(int i=1;i<=7;i++) fGenChamCO->AddEntry(Form("Chamber %i",i),i);  fGenChamCO->Resize(160,20); fGenChamCO->Select(kNotUsed);
228 }//GuiGen()
229 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
230 void RichConfig::GenAddSlot(Int_t id)
231 {//is invoked when any of generator check button is pressed
232   if(id==kGunZ){
233     fGenBG->GetButton(kGun1)->SetEnabled(kFALSE);  fGenF->HideFrame(fGenNprimCO); fGenF->HideFrame(fGenPmaxCO);
234     fGenBG->GetButton(kGun7)->SetEnabled(kFALSE);                                
235     fGenBG->GetButton(kBox )->SetEnabled(kFALSE);  fGenPidCO->Select(kProton);    fGenPminCO->Select(25);
236   } 
237   if(id==kGun1){
238     fGenBG->GetButton(kGunZ)->SetEnabled(kFALSE);  fGenF->HideFrame(fGenNprimCO); fGenF->HideFrame(fGenPmaxCO); 
239     fGenBG->GetButton(kGun7)->SetEnabled(kFALSE);  fGenPidCO->Select(kProton);    fGenPminCO->Select(25); fGenChamCO->Select(4);
240     fGenBG->GetButton(kBox )->SetEnabled(kFALSE);  
241   }
242   if(id==kGun7){
243     fGenBG->GetButton(kGunZ)->SetEnabled(kFALSE);  fGenF->HideFrame(fGenNprimCO);
244     fGenBG->GetButton(kGun1)->SetEnabled(kFALSE);                                fGenPidCO->Select(kProton); 
245     fGenBG->GetButton(kBox )->SetEnabled(kFALSE);  fGenF->HideFrame(fGenPmaxCO); fGenPminCO->Select(25);
246                                                    fGenF->HideFrame(fGenChamCO); 
247   } 
248   if(id==kBox){
249     fGenBG->GetButton(kGunZ)->SetEnabled(kFALSE);                                fGenNprimCO->Select(500);
250     fGenBG->GetButton(kGun1)->SetEnabled(kFALSE);                                fGenPidCO  ->Select(kProton);
251     fGenBG->GetButton(kGun7)->SetEnabled(kFALSE);                                fGenPminCO ->Select(15);       fGenPmaxCO->Select(15); 
252   }
253   if(id==kHijing){
254     fGenBG->GetButton(kHijing)->ChangeBackground(0xff0000);
255     fGenBG->GetButton(kHijingPara)->SetEnabled(kFALSE);
256     fGenBG->GetButton(kPythia)->SetEnabled(kFALSE);
257   }
258   if(id==kHijingPara){
259     fGenBG->GetButton(kHijing)->SetEnabled(kFALSE);   fGenNprimCO->Select(500);
260     fGenBG->GetButton(kPythia)->SetEnabled(kFALSE);
261   }
262   if(id==kPythia){
263     fGenBG->GetButton(kHijing)->SetEnabled(kFALSE);
264     fGenBG->GetButton(kHijingPara)->SetEnabled(kFALSE);
265   }
266 }//GenAddSlot()
267 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
268 void RichConfig::GenRemSlot(Int_t id)
269 {//is invoked when any of generator check button is released
270   if(id==kGunZ){
271     fGenBG->GetButton(kGun1)->SetEnabled();  fGenF->ShowFrame(fGenNprimCO);                                                                  
272     fGenBG->GetButton(kGun7)->SetEnabled();                                     fGenPidCO  ->Select(kNotUsed);
273     fGenBG->GetButton(kBox )->SetEnabled();  fGenF->ShowFrame(fGenPmaxCO);      fGenPminCO ->Select(kNotUsed);
274   } 
275   if(id==kGun1){
276     fGenBG->GetButton(kGunZ)->SetEnabled();  fGenF->ShowFrame(fGenNprimCO);
277     fGenBG->GetButton(kGun7)->SetEnabled();                                     fGenPidCO  ->Select(kNotUsed);
278     fGenBG->GetButton(kBox )->SetEnabled();  fGenF->ShowFrame(fGenPmaxCO);      fGenPminCO ->Select(kNotUsed);  
279   }
280   if(id==kGun7){
281     fGenBG->GetButton(kGunZ)->SetEnabled();  fGenF->ShowFrame(fGenNprimCO);
282     fGenBG->GetButton(kGun1)->SetEnabled();                                     fGenPidCO  ->Select(kNotUsed);
283     fGenBG->GetButton(kBox )->SetEnabled();  fGenF->ShowFrame(fGenPmaxCO);      fGenPminCO ->Select(kNotUsed); 
284                                              fGenF->ShowFrame(fGenChamCO); 
285   } 
286   if(id==kBox){
287     fGenBG->GetButton(kGunZ)->SetEnabled();                                     fGenNprimCO->Select(kNotUsed);
288     fGenBG->GetButton(kGun1)->SetEnabled();                                     fGenPidCO  ->Select(kNotUsed);
289     fGenBG->GetButton(kGun7)->SetEnabled();                                     fGenPminCO ->Select(kNotUsed);   fGenPmaxCO->Select(kNotUsed);
290                                                                                 fGenChamCO ->Select(kNotUsed);
291   }
292   if(id==kHijing){
293     fGenBG->GetButton(kHijing)->ChangeBackground(0xbebebe);
294     fGenBG->GetButton(kHijingPara)->SetEnabled();
295     fGenBG->GetButton(kPythia)->SetEnabled();
296   }
297   if(id==kHijingPara){
298     fGenBG->GetButton(kHijing)->SetEnabled();
299     fGenBG->GetButton(kPythia)->SetEnabled();
300   }
301   if(id==kPythia){
302     fGenBG->GetButton(kHijing)->SetEnabled();
303     fGenBG->GetButton(kHijingPara)->SetEnabled();
304   }
305 }//GenRemSlot()
306 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
307 void RichConfig::WriteGen(FILE *pF)
308 {
309   Int_t pid=fGenPidCO->GetSelected();
310   Float_t pmin=0.1*fGenPminCO->GetSelected(); //particle momentum, GeV
311   Float_t pmax=0.1*fGenPmaxCO->GetSelected(); //particle momentum, GeV
312   
313   fprintf(pF,"  AliGenCocktail *pG=new AliGenCocktail();\n\n");
314   
315   if(fGenBG->GetButton(kGunZ)->GetState()==kButtonDown)//1 particle along Z axis 
316     fprintf(pF,"  AliGenFixed *pGz=new AliGenFixed(1); pGz->SetPart(%i); pGz->SetMomentum(%.1f); pGz->SetOrigin(0,0,-200); pG->AddGenerator(pGz,\"Gz\",1);\n",pid,p);
317   
318   if(fGenBG->GetButton(kGun1)->GetState()==kButtonDown){//1 gun towards 1 RICH chamber
319     switch(fGenChamCO->GetSelected()){
320      case 1: fprintf(pF,"  AliGenFixed *pG1=new AliGenFixed(1); pG1->SetPart(%i); pG1->SetMomentum(%.1f);\n",pid,pmin); 
321              fprintf(pF,"               pG1->SetTheta(109.5);   pG1->SetPhi(10);  pG->AddGenerator(pG1,\"g1\",1);\n"); break;
322      case 2: fprintf(pF,"  AliGenFixed *pG2=new AliGenFixed(1); pG2->SetPart(%i); pG2->SetMomentum(%.1f);\n",pid,pmin);
323              fprintf(pF,"               pG2->SetTheta( 90.0);   pG2->SetPhi(10);  pG->AddGenerator(pG2,\"g2\",1);\n"); break;
324      case 3: fprintf(pF,"  AliGenFixed *pG3=new AliGenFixed(1); pG3->SetPart(%i); pG3->SetMomentum(%.1f);\n",pid,pmin);
325              fprintf(pF,"               pG3->SetTheta(109.5);   pG3->SetPhi(30);  pG->AddGenerator(pG3,\"g3\",1);\n"); break;
326      case 4: fprintf(pF,"  AliGenFixed *pG4=new AliGenFixed(1); pG4->SetPart(%i); pG4->SetMomentum(%.1f);\n",pid,pmin);
327              fprintf(pF,"               pG4->SetTheta( 90.0);   pG4->SetPhi(30);  pG->AddGenerator(pG4,\"g4\",1);\n"); break;
328      case 5: fprintf(pF,"  AliGenFixed *pG5=new AliGenFixed(1); pG5->SetPart(%i); pG5->SetMomentum(%.1f);\n",pid,pmin);
329              fprintf(pF,"               pG5->SetTheta( 70.5);   pG5->SetPhi(30);  pG->AddGenerator(pG5,\"g5\",1);\n"); break;
330      case 6: fprintf(pF,"  AliGenFixed *pG6=new AliGenFixed(1); pG6->SetPart(%i); pG6->SetMomentum(%.1f);\n",pid,pmin);
331              fprintf(pF,"               pG6->SetTheta( 90.0);   pG6->SetPhi(50);  pG->AddGenerator(pG6,\"g6\",1);\n"); break;
332      case 7: fprintf(pF,"  AliGenFixed *pG7=new AliGenFixed(1); pG7->SetPart(%i); pG7->SetMomentum(%.1f);\n",pid,pmin);
333              fprintf(pF,"               pG7->SetTheta( 70.5);   pG7->SetPhi(50);  pG->AddGenerator(pG7,\"g7\",1);\n"); break;
334     }    
335   }
336   
337   if(fGenBG->GetButton(kGun7)->GetState()==kButtonDown){//7 guns towards 7 RICH chambers
338     fprintf(pF,"  AliGenFixed *pG1=new AliGenFixed(1); pG1->SetPart(%i); pG1->SetMomentum(%.1f);pG1->SetTheta(109.5-3); pG1->SetPhi(10);\n",pid,pmin); 
339     fprintf(pF,"               pG->AddGenerator(pG1,\"g1\",1);\n");
340     fprintf(pF,"  AliGenFixed *pG2=new AliGenFixed(1); pG2->SetPart(%i); pG2->SetMomentum(%.1f);pG2->SetTheta( 90.0-3); pG2->SetPhi(10);\n",pid,pmin); 
341     fprintf(pF,"               pG->AddGenerator(pG2,\"g2\",1);\n");
342     fprintf(pF,"  AliGenFixed *pG3=new AliGenFixed(1); pG3->SetPart(%i); pG3->SetMomentum(%.1f);pG3->SetTheta(109.5-3); pG3->SetPhi(30);\n",pid,pmin); 
343     fprintf(pF,"               pG->AddGenerator(pG3,\"g3\",1);\n");
344     fprintf(pF,"  AliGenFixed *pG4=new AliGenFixed(1); pG4->SetPart(%i); pG4->SetMomentum(%.1f);pG4->SetTheta( 90.0-3); pG4->SetPhi(30);\n",pid,pmin); 
345     fprintf(pF,"               pG->AddGenerator(pG4,\"g4\",1);\n");
346     fprintf(pF,"  AliGenFixed *pG5=new AliGenFixed(1); pG5->SetPart(%i); pG5->SetMomentum(%.1f);pG5->SetTheta( 70.0-3); pG5->SetPhi(30);\n",pid,pmin); 
347     fprintf(pF,"               pG->AddGenerator(pG5,\"g5\",1);\n");
348     fprintf(pF,"  AliGenFixed *pG6=new AliGenFixed(1); pG6->SetPart(%i); pG6->SetMomentum(%.1f);pG6->SetTheta( 90.0-3); pG6->SetPhi(50);\n",pid,pmin); 
349     fprintf(pF,"               pG->AddGenerator(pG6,\"g6\",1);\n");
350     fprintf(pF,"  AliGenFixed *pG7=new AliGenFixed(1); pG7->SetPart(%i); pG7->SetMomentum(%.1f);pG7->SetTheta( 70.0-3); pG7->SetPhi(50);\n",pid,pmin); 
351     fprintf(pF,"               pG->AddGenerator(pG7,\"g7\",1);\n");
352   }  
353     
354   if(fGenBG->GetButton(kBox)->GetState()==kButtonDown){// box towards RICH phase space
355     fprintf(pF,"  AliGenBox *pB=new AliGenBox(%i);      pB->SetPart(%i);       pB->SetMomentumRange(%.1f,%.1f);\n",(int)fGenNprimCO->GetSelected(),pid,pmin,pmax); 
356     fprintf(pF,"             pB->SetThetaRange(65,115); pB->SetPhiRange(5,55); pG->AddGenerator(pB,\"b\",1);\n");
357   }     
358   
359   if(fGenBG->GetButton(kHijing)->GetState()==kButtonDown){//normal HIJING
360     fprintf(pF,"  AliGenHijing *pH=new AliGenHijing(-1);           pH->SetEnergyCMS(5500);        pH->SetReferenceFrame(\"CMS\");\n");
361     fprintf(pF,"                pH->SetProjectile(\"A\", 208, 82); pH->SetTarget(\"A\", 208, 82); pH->SetJetQuenching(0);\n");      
362     fprintf(pF,"                pH->SetShadowing(0);               pH->KeepFullEvent();           pH->SetSelectAll(0);\n");
363     fprintf(pF,"                pH->SetImpactParameterRange(0, 5); //fermi\n");
364     fprintf(pF,"  pG->AddGenerator(pH,\"h\",1);\n\n");
365   }
366   
367   if(fGenBG->GetButton(kHijingPara)->GetState()==kButtonDown){//parametrized HIJING 
368     fprintf(pF,"  AliGenHIJINGpara *pHP=new AliGenHIJINGpara(%i);\n",(int)fGenNprimCO->GetSelected());
369     fprintf(pF,"  pHP->SetMomentumRange(0,999); pHP->SetThetaRange(%f,%f); pHP->SetPhiRange(0,360);\n",Eta2Theta(8),Eta2Theta(-8));
370     fprintf(pF,"  pG->AddGenerator(pHP,\"hp\",1);\n\n");
371   }
372       
373   if(fGenBG->GetButton(kPythia)->GetState()==kButtonDown){//Pythia
374     fprintf(pF,"  AliGenPythia *pP=new AliGenPythia(-1);\n");
375     fprintf(pF,"  pP->SetMomentumRange(0,999); pP->SetPhiRange(20,80); pP->SetThetaRange(75,115);\n");
376     fprintf(pF,"  pP->SetYRange(-12,12);  pP->SetPtRange(0,1000);      pP->SetStrucFunc(kCTEQ4L);\n");
377     fprintf(pF,"  pP->SetProcess(kPyMb);  pP->SetEnergyCMS(14000);\n");      
378     fprintf(pF,"  pG->AddGenerator(pP,\"p\",1);\n\n");  
379   }
380   fprintf(pF,"  pG->Init();\n\n");
381 }//WriteGenerator()
382 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
383 void RichConfig::GuiDet(TGHorizontalFrame *pMainHF)
384 {
385   pMainHF->AddFrame(fDetBG=new TGButtonGroup(pMainHF,"Dets"));
386   fDetBG->Connect("Pressed(Int_t)" ,"RichConfig",this,"DetAddSlot(Int_t)");
387   fDetBG->Connect("Released(Int_t)","RichConfig",this,"DetRemSlot(Int_t)");
388     new TGCheckButton(fDetBG,"PIPE"  ,kPIPE));     new TGCheckButton(fDetBG,"ITS"   ,kITS));   new TGCheckButton(fDetBG,"TPC"   ,kTPC));
389     new TGCheckButton(fDetBG,"TRD"   ,kTRD));      new TGCheckButton(fDetBG,"TOF"   ,kTOF));   new TGCheckButton(fDetBG,"FRAME" ,kFRAME));         
390     new TGCheckButton(fDetBG,"MAG"   ,kMAG));      new TGCheckButton(fDetBG,"CRT"   ,kCRT));   new TGCheckButton(fDetBG,"HALL"  ,kHALL));         
391     new TGCheckButton(fDetBG,"PHOS"  ,kPHOS));     new TGCheckButton(fDetBG,"START" ,kSTART)); new TGCheckButton(fDetBG,"FMD"   ,kFMD));         
392     new TGCheckButton(fDetBG,"ABSO"  ,kABSO));     new TGCheckButton(fDetBG,"PMD"   ,kPMD));   new TGCheckButton(fDetBG,"DIPO"  ,kDIPO));         
393     new TGCheckButton(fDetBG,"EMCAL" ,kEMCAL));    new TGCheckButton(fDetBG,"VZERO" ,kVZERO)); new TGCheckButton(fDetBG,"MUON"  ,kMUON));         
394     new TGCheckButton(fDetBG,"ZDC"   ,kZDC));      new TGCheckButton(fDetBG,"SHILD" ,kSHILD));         
395 }
396 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
397 void RichConfig::DetAddSlot(Int_t id)
398 {//slot is invoked when any detector check button is pressed
399   if(id==kTRD || id==kTOF)     //TRD and TOF geometries depend on FRAME 
400     fDetBG->SetButton(kFRAME);
401 }
402 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
403 void RichConfig::DetRemSlot(Int_t id)
404 {//slot is invoked when any detector check button is released
405   if(id==kFRAME){
406     fDetBG->SetButton(kTRD,kFALSE); //switch off TRD and TOF when FRAME is switched off by user hence TRD&TOF depend on FRAME
407     fDetBG->SetButton(kTOF,kFALSE);
408   }
409 }
410 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
411 void RichConfig::WriteDet(FILE *pF)
412 {
413 //CORE detectors                  
414   if(fDetBG->GetButton(kPIPE )->GetState()) fprintf(pF,"\n  new AliPIPEv0(\"PIPE\",\"Beam Pipe\");\n");
415   if(fDetBG->GetButton(kSHILD)->GetState()) fprintf(pF,"\n  new AliSHILv2(\"SHIL\",\"Shielding Version 2\");\n");  
416   if(fDetBG->GetButton(kITS  )->GetState()){
417     fprintf(pF,"\n  AliITSvPPRasymmFMD *pIts =new AliITSvPPRasymmFMD(\"ITS\",\"ITS PPR detailed version\");\n");
418     fprintf(pF,"  pIts->SetMinorVersion(2); pIts->SetReadDet(kTRUE);\n");
419     fprintf(pF,"  pIts->SetThicknessDet1(200.); pIts->SetThicknessDet2(200.);\n");
420     fprintf(pF,"  pIts->SetThicknessChip1(200.); pIts->SetThicknessChip2(200.);\n");
421     fprintf(pF,"  pIts->SetRails(0); pIts->SetCoolingFluid(1);\n");
422     fprintf(pF,"  pIts->SetEUCLID(0);\n");
423   }  
424   if(fDetBG->GetButton(kTPC  )->GetState())  fprintf(pF,"\n  new AliTPCv2(\"TPC\",\"Default\");\n");
425   if(fDetBG->GetButton(kFRAME)->GetState())  fprintf(pF,"\n  AliFRAMEv2 *pFrame=new AliFRAMEv2(\"FRAME\",\"Space Frame\"); pFrame->SetHoles(1);\n");
426   if(fDetBG->GetButton(kTRD  )->GetState())  fprintf(pF,"\n  AliTRD *pTrd=new AliTRDv1(\"TRD\",\"TRD slow simulator\");\n");  
427   if(fDetBG->GetButton(kTOF  )->GetState()) fprintf(pF,"\n  new AliTOFv4T0(\"TOF\", \"normal TOF\");\n");
428 //central detectors  behind RICH
429   if(fDetBG->GetButton(kMAG  )->GetState()) fprintf(pF,"\n  new AliMAG(\"MAG\",\"Magnet\");\n");  
430   if(fDetBG->GetButton(kHALL )->GetState()) fprintf(pF,"\n  new AliHALL(\"HALL\",\"Alice Hall\");\n");
431 //forward detectors  
432   if(fDetBG->GetButton(kFMD  )->GetState()) fprintf(pF,"\n  new AliFMDv1(\"FMD\",\"normal FMD\");\n");
433   if(fDetBG->GetButton(kABSO )->GetState()) fprintf(pF,"\n  new AliABSOv0(\"ABSO\",\"Muon absorber\");\n");
434   if(fDetBG->GetButton(kDIPO )->GetState()) fprintf(pF,"\n  new AliDIPOv2(\"DIPO\",\"Dipole version 2\");\n");
435   if(fDetBG->GetButton(kMUON )->GetState()) fprintf(pF,"\n  new AliMUONv1(\"MUON\",\"default\");\n");
436   if(fDetBG->GetButton(kPMD  )->GetState()) fprintf(pF,"\n  new AliPMDv1(\"PMD\",\"normal PMD\");\n");
437   if(fDetBG->GetButton(kSTART)->GetState()) fprintf(pF,"\n  new AliSTARTv1(\"START\",\"START Detector\");\n");
438   if(fDetBG->GetButton(kVZERO)->GetState()) fprintf(pF,"\n  new AliVZEROv2(\"VZERO\",\"normal VZERO\");\n");
439   if(fDetBG->GetButton(kZDC  )->GetState()) fprintf(pF,"\n  new AliZDCv2(\"ZDC\",\"normal ZDC\");\n");
440 //different phase space detectors  
441   if(fDetBG->GetButton(kPHOS )->GetState()) fprintf(pF,"\n  new AliPHOSv1(\"PHOS\",\"IHEP\");\n");
442   if(fDetBG->GetButton(kEMCAL)->GetState()) fprintf(pF,"\n  new AliEMCALv1(\"EMCAL\",\"G56_2_55_19_104_14\");\n");
443   if(fDetBG->GetButton(kCRT  )->GetState()) fprintf(pF,"\n  new AliCRTv0(\"CRT\",\"normal ACORDE\");\n");
444 }
445 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
446 void RichConfig::GuiBatch(TGHorizontalFrame *pMainF)
447 {
448   TGGroupFrame *pSimF=new TGGroupFrame(pMainF,"Simu"); pMainF->AddFrame(pSimF);    
449   pSimF->AddFrame(fSimBG=new TGButtonGroup(pSimF,""    ));
450     new TGCheckButton(fSimBG,   "Primary"         ,kPrim     ));   fSimBG->SetButton(kPrim);
451     new TGCheckButton(fSimBG,   "Transport"       ,kTransport));   fSimBG->SetButton(kTransport);
452   pSimF->AddFrame (fSDigBG=new TGButtonGroup(pSimF,""  ));
453     new TGRadioButton(fSDigBG,  "No SDigits"      ,kNo       ));   
454     new TGRadioButton(fSDigBG,  "SDigits CORE"    ,kAll      ));  
455     new TGRadioButton(fSDigBG,  "SDigits RICH"    ,kOnly     ));   fSDigBG->SetButton(kOnly);
456   pSimF->AddFrame (fDigBG=new TGButtonGroup(pSimF,""   ));
457     new TGRadioButton(fDigBG,   "No Digits"       ,kNo       ));   
458     new TGRadioButton(fDigBG,   "Digits CORE"     ,kAll      ));  
459     new TGRadioButton(fDigBG,   "Digits RICH"     ,kOnly     ));   fDigBG->SetButton(kOnly); 
460   pSimF->AddFrame(fRawBG=new TGButtonGroup(pSimF,""    ));
461     new TGRadioButton(fRawBG,   "No RAW files"    ,kNo       ));   fRawBG->SetButton(kNo);
462     new TGRadioButton(fRawBG,   "RAW DDL"         ,kRawDdl   ));
463     new TGRadioButton(fRawBG,   "RAW DATE"        ,kRawDate  ));
464     new TGRadioButton(fRawBG,   "RAW ROOT"        ,kRawRoot  ));
465     
466   TGCompositeFrame *pRecF=new TGGroupFrame(pMainF,"Reco"); pMainF->AddFrame(pRecF);    
467   pRecF->AddFrame(fClusBG=new TGButtonGroup(pRecF,""   ));
468     new TGRadioButton(fClusBG,  "No Clusters"     ,kNo       ));  
469     new TGRadioButton(fClusBG,  "Clusters CORE"   ,kAll      ));  
470     new TGRadioButton(fClusBG,  "Clusters RICH"   ,kOnly     ));   fClusBG->SetButton(kOnly);
471     
472   pRecF->AddFrame(fRecoBG=new TGButtonGroup(pRecF,""   ));                       fRecoBG->Connect("Pressed(Int_t)","RichConfig",this,"SlotBatch(Int_t)");
473     new TGCheckButton(fRecoBG,  "Find ESD tracks" ,kTrack    ));  
474     new TGCheckButton(fRecoBG,  "Find vertex"     ,kVertex   ));  
475     new TGCheckButton(fRecoBG,  "Add info ESD"    ,kEsd      ));
476 }
477 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
478 void RichConfig::SlotBatch(Int_t id)
479 {//slot is invoked when any button in fRecoBG is pressed
480   if(id==kTrack){
481     fSDigBG->SetButton(kAll); 
482     fDigBG->SetButton(kAll);
483     fClusBG->SetButton(kAll);
484     fDetBG->SetButton(kITS);
485     fDetBG->SetButton(kTPC);
486     fDetBG->SetButton(kTRD);
487   }
488 }
489 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
490 void RichConfig::WriteBatch()
491 {//creates Batch.C file
492   char *sBatchName="RichBatch";
493   FILE *fp=fopen(Form("%s.C",sBatchName),"w"); if(!fp){Info("CreateBatch","Cannot open output file: %s.C",sBatchName);return;}
494 //header and debug   
495                                                        fprintf(fp,"void %s(const Int_t iNevents,const Bool_t isDebug,const char *sConfigFileName)\n{\n",sBatchName);
496                                                        fprintf(fp,"  gSystem->Exec(\"rm -rf *.root hlt hough fort* raw* ZZZ*\");\n");
497                                                        fprintf(fp,"  if(isDebug)   AliLog::SetGlobalDebugLevel(AliLog::kDebug);\n");
498                                                        fprintf(fp,"  gBenchmark->Start(\"ALICE\");\n  TDatime time;\n\n");
499 //simulation section  
500                                                        fprintf(fp,"  AliSimulation     *pSim=new AliSimulation(sConfigFileName);\n");
501 //generate initial kinematics  
502   if(fSimBG->GetButton(kPrim)->GetState()) 
503                                                        fprintf(fp,"  pSim->SetRunGeneration(kTRUE);           //initial kinematics generated\n");
504   else
505                                                        fprintf(fp,"  pSim->SetRunGeneration(kFALSE);          //no initial kinematics generated\n");
506 //transport and hit creations  
507   if(fSimBG->GetButton(kTransport)->GetState()) 
508                                                        fprintf(fp,"  pSim->SetRunSimulation(kTRUE);                  //transport and hits creation\n");
509   else
510                                                        fprintf(fp,"  pSim->SetRunSimulation(kFALSE);                 //no transport and hits creation\n");
511 //sdigits  
512   if     (fSDigBG->GetButton(kNo)    ->GetState())     fprintf(fp,"  pSim->SetMakeSDigits(\"\");                     //no sdigits created\n");
513   else if(fSDigBG->GetButton(kAll)   ->GetState())     fprintf(fp,"  pSim->SetMakeSDigits(\"ITS TPC TRD TOF RICH\"); //sdigits created for these detectors\n");
514   else if(fSDigBG->GetButton(kOnly)  ->GetState())     fprintf(fp,"  pSim->SetMakeSDigits(\"RICH\");                 //sdigits created for RICH only\n");
515 //digits  
516   if     (fDigBG->GetButton(kNo)    ->GetState())      fprintf(fp,"  pSim->SetMakeDigits(\"\");                      //no digits created\n");
517   else if(fDigBG->GetButton(kAll)   ->GetState())      fprintf(fp,"  pSim->SetMakeDigits(\"ITS TPC TRD TOF RICH\");  //digits created for these detectors\n");
518   else if(fDigBG->GetButton(kOnly)  ->GetState())      fprintf(fp,"  pSim->SetMakeDigits(\"RICH\");                  //digits created for RICH only\n");
519 //raw data generation  
520   if     (fRawBG->GetButton(kRawDdl)->GetState())      fprintf(fp,"  pSim->SetWriteRawData(\"ITS TPC TRD TOF RICH\");//raw data in DDL  format for these detectors\n");
521   else if(fRawBG->GetButton(kRawDate)->GetState())     fprintf(fp,"  pSim->SetWriteRawData(\"ITS TPC TRD TOF RICH\",\".date\");//raw data in DATE format for these detectors\n");
522   else if(fRawBG->GetButton(kRawRoot)->GetState())     fprintf(fp,"  pSim->SetWriteRawData(\"ITS TPC TRD TOF RICH\",\".root\");//raw data in ROOT format for these detectors\n");
523   
524                                                        fprintf(fp,"  pSim->Run(iNevents);\n  delete pSim;\n\n");
525                                                        fprintf(fp,"  delete AliRICHParam::Instance();\n\n");
526
527
528
529 //reconstraction section  
530   if(!fClusBG->GetButton(kNo)->GetState()){
531                                                        fprintf(fp,"  AliReconstruction *pRec=new AliReconstruction;\n");
532     if     (fClusBG->GetButton(kAll)   ->GetState())   fprintf(fp,"  pRec->SetRunLocalReconstruction(\"ITS TPC TRD TOF RICH\");        //clusters created for these detectors\n");
533     else if(fClusBG->GetButton(kOnly)  ->GetState())   fprintf(fp,"  pRec->SetRunLocalReconstruction(\"RICH\");       //clusters created for RICH only\n");
534     
535     if(fRecoBG->GetButton(kVertex)->GetState())
536                                                        fprintf(fp,"  pRec->SetRunVertexFinder(kTRUE);                 //vertex created\n");
537     else
538                                                        fprintf(fp,"  pRec->SetRunVertexFinder(kFALSE);                //no vertex creation\n");
539     
540     if(fRecoBG->GetButton(kTrack)->GetState())
541                                                        fprintf(fp,"  pRec->SetRunTracking(\"ITS TPC TRD TOF RICH\");  //tracks are created\n");
542     else
543                                                        fprintf(fp,"  pRec->SetRunTracking(\"\");                      //not run ESD track task\n");
544     
545     if(fRecoBG->GetButton(kEsd)->GetState())
546                                                        fprintf(fp,"  pRec->SetFillESD(\"ITS TPC TRD TOF RICH\");      //run ESD add info task\n");      
547     else
548                                                        fprintf(fp,"  pRec->SetFillESD(\"\");                          //not run ESD add info task\n");
549     
550     
551                                                        fprintf(fp,"  pRec->Run();delete pRec;\n\n");         
552   }
553 //benchmarks  
554                                                        fprintf(fp,"  cout<<\"!!!!!!!!!!!!Info in <my/Batch.C>: Start time: \";time.Print();\n");
555                                                        fprintf(fp,"  cout<<\"!!!!!!!!!!!!Info in <my/Batch.C>: Stop  time: \";time.Set();  time.Print();\n");
556                                                        fprintf(fp,"  gBenchmark->Show(\"ALICE\");\n");
557   
558                                                        fprintf(fp,"  gSystem->Exec(\"play -c 2 ~/my/end.wav\");\n");
559                                                        fprintf(fp,"  gSystem->Exec(\"touch ZZZ______finished_______ZZZ\");\n}\n");
560   fclose(fp);  
561 }//WriteBatch()
562 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
563 void RichConfig::ExitSlot()
564 {
565 //slot to be invoked by clik on the Create button  
566   WriteConfig();
567   WriteBatch();
568   SendCloseMessage();
569   gApplication->Terminate(0);
570 }
571 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
572 void RichConfig::WriteConfig()
573 {   
574   FILE *pF=fopen(fFileName,"w"); if(!pF){Info("CreateConfigFile","Cannot open output file:%sn",fFileName);return;}
575   
576   fprintf(pF,"void Config()\n");
577   fprintf(pF,"{\n");
578   fprintf(pF,"\n  ::Info(\"\\n\\n\\n----------> RICH private config\",\"Start\");\n"); 
579 //Random
580   fprintf(pF,"  gRandom->SetSeed(123456);//put 0 to use system time\n\n");    
581 //Geant  
582   fprintf(pF,"  gSystem->Load(\"libgeant321\");\n");
583   fprintf(pF,"  new TGeant3TGeo(\"C++ Interface to Geant3\");\n\n");
584 //File
585   fprintf(pF,"  AliRunLoader *pAL=AliRunLoader::Open(\"galice.root\",AliConfig::GetDefaultEventFolderName(),\"recreate\");\n");    
586   fprintf(pF,"  pAL->SetCompressionLevel(2);\n");
587   fprintf(pF,"  pAL->SetNumberOfEventsPerFile(1000);\n");
588   fprintf(pF,"  gAlice->SetRunLoader(pAL);\n\n");
589 //Decayer  
590   if(fDecayerB->GetState()==kButtonDown){   
591     fprintf(pF,"  TVirtualMCDecayer *pDecayer=new AliDecayerPythia();\n");
592     fprintf(pF,"  pDecayer->SetForceDecay(kAll);\n"); 
593     fprintf(pF,"  pDecayer->Init();\n"); 
594     fprintf(pF,"  gMC->SetExternalDecayer(pDecayer);\n\n");
595   }
596   WritePhys(pF); //physics processes
597   
598 //Field
599        if(fMagBG->GetButton(kFld0)->GetState())     fprintf(pF,"  gAlice->SetField(0);        //no field\n\n");
600   else if(fMagBG->GetButton(kFld2)->GetState())     fprintf(pF,"  gAlice->SetField(new AliMagFMaps(\"Maps\",\"Maps\",2,1,10,0));//0.2 Tesla field\n\n");
601   else if(fMagBG->GetButton(kFld4)->GetState())     fprintf(pF,"  gAlice->SetField(new AliMagFMaps(\"Maps\",\"Maps\",2,1,10,1));//0.4 Tesla field\n\n");
602   else if(fMagBG->GetButton(kFld5)->GetState())     fprintf(pF,"  gAlice->SetField(new AliMagFMaps(\"Maps\",\"Maps\",2,1,10,2));//0.5 Tesla field\n\n");
603   else if(fMagBG->GetButton(kFld_2)->GetState())    fprintf(pF,"  gAlice->SetField(new AliMagFMaps(\"Maps\",\"Maps\",2,-1,10,0));//-0.2 Tesla field\n\n");
604   else if(fMagBG->GetButton(kFld_4)->GetState())    fprintf(pF,"  gAlice->SetField(new AliMagFMaps(\"Maps\",\"Maps\",2,-1,10,1));//-0.4 Tesla field\n\n");
605   else if(fMagBG->GetButton(kFld_5)->GetState())    fprintf(pF,"  gAlice->SetField(new AliMagFMaps(\"Maps\",\"Maps\",2,-1,10,2));//-0.5 Tesla field\n\n");
606   
607   fprintf(pF,"  pAL->CdGAFile();\n\n");                                 //????       
608 //Generator 
609   WriteGen(pF);//generator
610 //BODY-ALIC 
611   fprintf(pF,"  new AliBODY(\"BODY\",\"Alice envelop\");\n\n");
612 //RICH
613   WriteRich(pF);  //private RICH part
614   WriteDet(pF);  //other detectors
615 //end of Config.C file:  
616   fprintf(pF,"\n  ::Info(\"----------> RICH private config\",\"Stop\\n\\n\\n\");\n"); 
617   fprintf(pF,"}\n");
618   fclose(pF);  
619 }//WriteConfig()
620 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
621 void RichConfig()
622 {
623    new RichConfig("Config.C");
624 }