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