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