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