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