FlyoDoc_2011 Pisa 2011 by GmP --- 011
|
00001 /*************************************************************************** 00002 * Copyright (C) 2009 by giuseppe Pierazzini * 00003 * giuseppe@pierazzini.it * 00004 * * 00005 * * 00006 * This program is distributed in the hope that it will be useful, * 00007 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00008 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * 00009 * * 00010 * Dipartimento di Fisica E.Fermi / INFN Pisa Italy * 00011 ***************************************************************************/ 00012 #include "flyoh.h" 00013 00024 Reagas::Reagas() 00025 { 00026 00027 Gascls= new Frammenti[1]; 00028 gletti=0; 00029 rec=0; 00030 00031 Gout<<"\n Reagas Done..."; 00032 npp_gas=np_gas=idnow=0; 00033 00034 if ( BloccoGas>evento_.Mxev ) BloccoGas=evento_.Mxev+1; 00035 00036 cout<<"\n Gas: Reading block of "<<BloccoGas<< " Gas_ev"<<endl; 00037 Gout<<"\n Gas: Reading block of "<<BloccoGas<< " Gas_ev"<<endl; 00038 } 00039 00040 00041 Reagas::~Reagas() 00042 { 00043 } 00044 //=============================================== 00045 void Reagas::Read() 00046 00047 { 00048 00049 char line[128]; 00050 string label,simbolo; 00051 int npp=0,ntp=0; 00052 int nev=0, p_gas=0; 00053 int Gasskip=0; 00054 00055 00056 // if ( aperta==0 ) 00057 00058 if ( !Card_gas.is_open() ) 00059 { 00060 00061 Card_gas.open ( "../../Flukadati/KsuO.txt", ios::in ); 00062 if ( !Card_gas ) 00063 { 00064 Gout<<"\n Input file out.txt NOT opened "; 00065 Gout<<"\n no input files ..program stop !!! \n"<<endl; 00066 exit ( -1 ); 00067 } 00068 else 00069 { 00070 cout<<"\n REAGAS: Reading data gas opened.."<<endl; 00071 Gout<<"\n REAGAS: Reading data gas opened.."<<endl; 00072 } 00073 00074 } 00075 00076 // qui definisco lo spazio per i dati letti 00077 delete[] Gascls; 00078 00079 if ( BloccoGas> ( evento_.Mxev-Eventi_Fatti ) ) BloccoGas= ( evento_.Mxev-Eventi_Fatti )+2; 00080 00081 Gascls= new Frammenti[BloccoGas]; 00082 00083 p_gas=-1; 00084 00085 00086 Card_gas.getline ( line, 120 ); 00087 while ( !Card_gas.eof() ) 00088 { 00089 00090 // Decodifico la linea 00091 stringstream scheda; 00092 scheda<<line; 00093 scheda>>simbolo; 00094 00095 // cout<<"\n Gas: "<<p_gas<<" "<<ntp<<" "<< line<< " == labl: "<<simbolo<<flush; 00096 00097 if ( simbolo.size() <1 ) 00098 { 00099 Card_gas.getline ( line, 120 ); 00100 continue; 00101 } 00102 if ( simbolo.size() ==0 ); 00103 else if ( simbolo.size() != 0 ) 00104 { 00105 00106 if ( simbolo=="Evento" ) 00107 { 00108 gletti++; 00109 if ( gletti>=GasBegin ) 00110 { 00111 00112 p_gas++; 00113 // if ( p_gas>BloccoGas ) break; 00114 00115 scheda>> nev; 00116 scheda>> npp; 00117 npp-=2; 00118 Gascls[p_gas].Np= npp; // ricavo il numero delle particelle del cluster 00119 Gascls[p_gas].Pgas = new NataInGas[npp]; // Creo il buffer per npp particelle 00120 ntp=0; 00121 } 00122 else Gasskip++; 00123 } 00124 // memorizzo le particelle 00125 // cerco il puntatore standard della particella e memorizzo il momento 00126 else if ( ntp<npp ) 00127 { 00128 00129 double px,py,pz,mas; 00130 scheda>>px>>py>>pz>>mas; 00131 Gascls[p_gas].Pgas[ntp].mp= Matter->Pntmatter ( simbolo.c_str() ); 00132 00133 Gascls[p_gas].Pgas[ntp].px= px; 00134 Gascls[p_gas].Pgas[ntp].py= py; 00135 Gascls[p_gas].Pgas[ntp].pz= pz; 00136 Gascls[p_gas].Pgas[ntp].massa= abs ( mas ); 00137 ntp++; 00138 } 00139 } 00140 if ( p_gas> ( BloccoGas-2 ) ) break; 00141 rec++; 00142 Card_gas.getline ( line, 120 ); 00143 } 00144 00145 Gout<<"\n REAGAS: Ev "<<Eventi_Fatti<<" Gas event read "<<nev<<" new data blocco "<<p_gas+1<< " skipped "<<Gasskip<<endl; 00146 cout<<"\n REAGAS: Ev "<<Eventi_Fatti<<" Gas event read "<<nev<<" new data blocco "<<p_gas+1<< " skipped "<<Gasskip<<endl; 00147 00148 if ( p_gas<BloccoGas-2) 00149 { 00150 int evegas_disponibili =Eventi_Fatti+p_gas; 00151 if ( evento_.Mxev>evegas_disponibili ) 00152 { 00153 evento_.Mxev=evegas_disponibili; // to avoid crash... 00154 00155 Gout<<"\n REAGAS: Event gas at disposal " << evegas_disponibili 00156 << " Num. maxev redifined to: "<< evento_.Mxev<<flush; 00157 cout<<"\n REAGAS: Event gas at disposal " << evegas_disponibili 00158 << " Num. maxev redifined to: "<< evento_.Mxev<<flush; 00159 } 00160 } 00161 } 00162 //============================================= 00163 00164 Particella * Reagas::Get_GasInt ( int fiot, Particella *pup ) 00165 { 00166 00167 Particella *pr=0; 00168 // Partname= Dum; 00169 00170 00171 if ( np_gas==0 ) // first call in the cluster 00172 { 00173 npp_gas= Gascls[fiot].Np; 00174 00175 } 00176 else if ( np_gas>=npp_gas ) 00177 { 00178 np_gas=0; 00179 return 0; 00180 } 00181 00182 Part_db *pmt; 00183 pmt=Gascls[fiot].Pgas[np_gas].mp; 00184 00185 if ( pmt==0 ) 00186 { 00187 np_gas=0; 00188 return 0; 00189 } 00190 00191 // trasformo i K0 in Kl/Ks al 50% 00192 00193 Partname=pmt->Get_Nome(); 00194 if ( Partname==Kap0||Partname==A_Kap0 ) 00195 { 00196 if ( Pran() >0.5 ) Partname=Kaps; 00197 else Partname=Kapl; 00198 } 00199 00200 pr= SelRea->NuovaPart ( Partname ); 00201 pr->Set_Fato ( Nata,1 ); 00202 pup->cls=pr; 00203 pr->up=pup; 00204 pr->cls=pr->dw=pr->lf=pr->rg=0; 00205 pr->Gx=pr->X=pup->X; // all born in the same place... 00206 double gpx=Gascls[fiot].Pgas[np_gas].px; 00207 double gpy=Gascls[fiot].Pgas[np_gas].py; 00208 double gpz=Gascls[fiot].Pgas[np_gas].pz; 00209 double mas=Gascls[fiot].Pgas[np_gas].massa; // aggiustare la massa ... 00210 pr->Gp.setvn ( gpx,gpy,gpz,mas ); 00211 pr->P=pr->Gp; 00212 pr->Vers=pr->P.NVerso(); 00213 pr->Pbar=pr->P; 00214 np_gas++; 00215 //pr->Stampa_questa_particella(); 00216 00217 00218 00219 00220 00221 return pr; 00222 } 00223 00224 //================================================== 00225 void Reagas::Print ( int prima,int fine ) 00226 { 00227 Part_db *pmt=0; 00228 00229 Gout<<"\n B U F F E R FLUKA blocco debug da " 00230 << prima <<" a "<<fine <<" dei "<<gletti<<" creati"<<endl; 00231 00232 for ( int curr=prima; curr<fine;curr++ ) 00233 { 00234 if ( curr>BloccoGas ) break; 00235 int npp=Gascls[curr].Np; 00236 00237 Gout<<"\n Cls_ev "<< curr <<" Particelle "<<npp; 00238 for ( int n=0; n<npp;n++ ) 00239 { 00240 pmt=Gascls[curr].Pgas[n].mp; 00241 if ( pmt>0 ) 00242 { 00243 Gout<<"\n "<< setw ( 4 ) <<n 00244 <<setw ( 7 ) <<pmt->Get_Nome() 00245 <<" "<< setw ( 8 ) <<Gascls[curr].Pgas[n].px 00246 <<" "<< setw ( 8 ) <<Gascls[curr].Pgas[n].py 00247 <<" "<< setw ( 8 ) <<Gascls[curr].Pgas[n].pz; 00248 if ( pmt==ptr_boo ) Gout<<" particella sconosciuta! "; 00249 } 00250 00251 } 00252 Gout<<"\n fine "<<endl; 00253 } 00254 00255 } 00256 00257 //===================================================================== 00258 // M k C l u s t e r 00259 //==================================================================== 00260 00261 void Particella:: 00262 MkCluster () 00263 { 00264 Particella *pr,*pup; 00265 // qui si leggono i dati prodotti da fluka. 00266 if ( ClsG%BloccoGas==0 ) 00267 { 00268 if ( Gasdati==0 ) Gasdati = new Reagas; 00269 Gasdati->Read(); 00270 cout<<"\n Gasdati letti..."<<std::endl<<std::endl; 00271 // Gasdati->Print ( 30,40 ); 00272 ClsG=0; 00273 } 00274 // Fluka(); 00275 // qui chiamare fluka???????????????????? o un generatore di particelle 00276 //define the particle cluster...according with Fluka generation; 00277 // Aggiorna_link (Particella * pup, Particella * prg, Particella * pdw, Particella * plf) 00278 00279 pup = this; 00280 dw=0; 00281 // Generate the read list in particles (level zero) 00282 while ( pup ) 00283 { 00284 pr= Gasdati->Get_GasInt ( ClsG, pup ); //Ricavo una particella dalla interazione gas n. ClsG. 00285 if ( pr==0 ) break; // fine delle particelle disponibili nel cluster selezionato 00286 // Gout<<"\n Evento "<<Eventi_Fatti<<" Cls "<<ClsG<<" sele "<<pr->nome; 00287 pup=pr; 00288 } 00289 ClsG++; 00290 SelRea->Gasint_Done++; 00291 00292 00293 // indice dell'ultima particella letta dal file 00294 GasIdo=SelRea->Lastpart->Get_Ido(); 00295 //ultima particella letta dal file per questa interazione 00296 Particella *GasUltima=SelRea->Lastpart; 00297 00298 // Generate the decay of the read particles if one ( level one) 00299 00300 pr=SelRea->LastpartSave->next; 00301 while ( pr!=0&&pr!=GasUltima ) 00302 { 00303 pr->Make_decay_chain (); 00304 pr=pr->next; 00305 } 00306 00307 } 00308 //============= 00309 void Particella::Make_decay_chain () 00310 { 00311 00312 00313 // costruisce la reazione iterativamente generando i decadimenti di 00314 // ciascuna particella coinvolta nella reazione. 00315 00316 if ( dw!=0 ) return; // no decay particles 00317 00318 int canali = pointer_db->ncan; //punta alla lista dei decadimenti della particella padre [this] 00319 if ( canali==0 ) return; //no decay! 00320 00321 Particella *pa,*pb=0,*pc=0; 00322 double Prob= Pran(); 00323 double Tprob=0.0; 00324 00325 int icn=0; 00326 for ( int i=0;i<canali;i++ ) 00327 { 00328 Tprob+=pointer_db->Canale[i].rate; 00329 icn=i; 00330 if ( Prob<Tprob ) break; // attenzione meglio se Tprob_max>=1. !!! 00331 } 00332 00333 if ( pointer_db->Canale[icn].frammenti==2 ) 00334 { 00335 00336 pa=Decay_in_2 ( pointer_db->Canale[icn].nomea,pointer_db->Canale[icn].nomeb ); 00337 pb=pa->rg; 00338 pc=0; 00339 00340 } 00341 else if ( pointer_db->Canale[icn].frammenti==3 ) 00342 { 00343 pa = Decay_in_3 ( pointer_db->Canale[icn].nomea, pointer_db->Canale[icn].nomeb,pointer_db->Canale[icn].nomec ); 00344 pb=pa->rg->dw; 00345 pc=pb->rg; 00346 } 00347 else 00348 { 00349 Gout<<"\n Make_decay_chain: Error in decay data base partcle list !!! "<<nome<<endl; 00350 exit ( 0 ); 00351 } 00352 00353 if ( pa!=0 ) pa->Make_decay_chain (); 00354 if ( pb!=0 ) pb->Make_decay_chain (); 00355 if ( pc!=0 ) pc->Make_decay_chain (); 00356 00357 } 00358 00359 00360 00361 00362 00363 00364 00365