FlyoDoc_2011 Pisa 2011 by GmP --- 011
|
00001 /*************************************************************************** 00002 ------------------- 00003 begin : Sun Nov 26 2000 00004 copyright : (C) 2000 by Giuseppe m Pierazzini 00005 email : pierazzini@unipi.it 00006 *************************************************************************** 00007 * * 00008 * NA48 simulation program. 1992----2005 * 00009 * * 00010 ***************************************************************************/ 00011 #define UNDEF 6 00012 #define ESTERNO 1 00013 #define INTERNO 0 00014 #define INBUCO -1 00015 #define NEUTRI 1 00016 #define CARICHI 2 00017 #define ALLCHR 3 00018 00019 #include "flyoh.h" 00020 #include "devfluka.h" 00021 00022 using namespace GmpConst; 00023 using namespace std; 00024 00033 //============================================================== 00034 // P A R T I C E L L A Construttor 00035 //===================================================================== 00036 00037 Particella::Particella () 00038 { 00039 00040 if ( ( pointer_db=Matter->Get_matter ( Partname, this )) == 0 ) 00041 { 00042 Gout<<"\n Particella() Partname error.... "<<Partname<<std::endl; 00043 exit ( 0 ); 00044 } 00045 00046 // Create a new reaction with links. 00047 SelRea->Totpart++; 00048 ido = SelRea->Totpart; 00049 00050 if ( SelRea->Lastpart != 0 ) SelRea->Lastpart->next = this; 00051 SelRea->Lastpart = this; 00052 this->next = 0; 00053 id=0; //vedi Set_Id(); 00054 fato = Undef; 00055 devhit=Ifato =devstory=0; 00056 if ( charg ==0 ) type = Neut; 00057 else type = Char; 00058 00059 if ( massa==0.0&&width==0.0&&ctau==0.0 ) type=Res; 00060 00061 nata=0; 00062 rea_madre=LastReaction; 00063 Pair_Production=Brems_Production=0; // 1 attiva la bremsstrhalung, 2 attiva la pair prodution... 00064 P.Riposo(massa); 00065 Qpatre=Pburst=Pbar=Gp=P; 00066 Gx.Reset(); 00067 00068 // Gout<<"\n Part P.mq %12.6lf %12.6lf %12.5lg %12.5lg",massa,P.m,P.mq,Gp.mq); 00069 00070 pathok=path_max=path_done=last_path=0.0; 00071 cstar=10.; // flag esplicitamente voluta...vedi Voldec... 00072 00073 //------------------links---- 00074 up = 0; 00075 rg = 0; 00076 dw = 0; 00077 lf = 0; 00078 cls = 0; 00079 00080 } 00081 00082 //============================================================== 00083 // A g g i o r n a _ l i n k 00084 //=============================================================== 00085 void Particella:: 00086 Aggiorna_link ( Particella * pup, Particella * prg, 00087 Particella * pdw, Particella * plf ) 00088 { 00089 if ( pup != 0 ) up = pup; 00090 if ( prg != 0 ) rg = prg; 00091 if ( pdw != 0 ) dw = pdw; 00092 if ( plf != 0 ) lf = plf; 00093 } 00094 void Particella:: 00095 Aggiusta_link ( Particella * pup, Particella * prg, 00096 Particella * pdw, Particella * plf ) 00097 { 00098 Aggiorna_link ( pup,prg,pdw,plf ); 00099 //restaura i links... 00100 if ( pup != 0 ) pup->dw=this; 00101 if ( prg != 0 ) prg->lf=this; 00102 if ( pdw != 0 ) pdw->up=this; 00103 if ( plf != 0 ) plf->rg=this; 00104 00105 } 00106 void Particella:: 00107 Aggiorna_link_Bullet ( Particella * pbers ) 00108 { 00109 if ( pbers!= 0 ) rg = pbers; 00110 } 00111 00112 00113 Particella * Particella:: 00114 Decay_in_2 ( const char *pa_nome,const char *pb_nome ) 00115 { 00116 // pattern == DECAY2 :padre=> pa,pb 00117 00118 // Gout<<"\n Ev Dec1.out "<<Eventi_Fatti<<" "<<nome<<" ==> " 00119 // <<pa_nome<<" "<<pb_nome<<flush; 00120 00121 00122 Particella *padre,*pa,*pb; 00123 padre=this; 00124 pa = SelRea->NuovaPart ( pa_nome ); 00125 00126 pb = SelRea->NuovaPart ( pb_nome ); 00127 00128 00129 00130 // Aggiorna_link ( up, rg,dw,lf ) 00131 padre->Aggiorna_link ( 0, 0, pa, 0 ); 00132 pa->Aggiorna_link ( padre, pb, 0, 0 ); 00133 pb->Aggiorna_link ( padre, 0, 0, pa ); 00134 pa->Set_Id(); 00135 pb->Set_Id(); 00136 // Gout<<"\n Ev Dec3.out "<<Eventi_Fatti<<" "<<nome<<" ==> " 00137 // <<pa->nome<<" "<<pb->nome<<" [ "<<pa<<" "<<pb<<" ] "<<flush; 00138 00139 return pa; 00140 } 00141 //==================== 00142 Particella * Particella:: 00143 Decay_in_3 (const char *pa_nome, const char *pb_nome,const char *pc_nome ) 00144 { 00145 // three bodies decay....pattern == DECAY3; 00146 // padre -> pa+res2 00147 // res2 -> pb + pc; 00148 // but the muons... 00149 00150 Particella *padre,*pa,*pb; 00151 // const char *word; 00152 padre=this; 00153 00154 { 00155 pa = padre->Decay_in_2 (pa_nome,Res2); 00156 pb = pa->rg->Decay_in_2 ( pb_nome,pc_nome ); 00157 } 00158 return pa; 00159 } 00160 00161 //============ 00162 Particella * Particella:: 00163 Decay_in_4 ( const char *pa_nome, const char *pb_nome,const char *pc_nome, 00164 const char *pd_nome ) 00165 { 00166 Particella *padre,*pa,*pb; 00167 padre=this; 00168 //decadimento a 4 padre-> pa+ res3 00169 //decadimento a 3 Res3 -> pb + pc + pd 00170 // 00171 pa = padre->Decay_in_2 (pa_nome, Res3); 00172 pb=pa->rg->Decay_in_3(pb_nome,pc_nome,pd_nome); 00173 return pa; 00174 } 00175 00176 00177 //============ 00178 Particella * Particella:: 00179 Decay_in_5 ( const char *pa_nome, const char *pb_nome,const char *pc_nome, 00180 const char *pd_nome ,const char *pe_nome ) 00181 { 00182 Particella *padre,*pa,*pb; 00183 padre=this; 00184 00185 //decadimento a 5 padre-> pa+Res4 00186 //decadimento a 4 Res4 -> pb + pc + pd + pe 00187 pa = padre->Decay_in_2 (pa_nome, Res4); 00188 pb=pa->rg->Decay_in_4 (pb_nome,pc_nome,pd_nome,pe_nome); 00189 return pa; 00190 } 00191 00193 // 00194 void Particella::Save_Link() 00195 { 00196 lfsav=lf; 00197 rgsav=rg; 00198 upsav=up; 00199 dwsav=dw; 00200 if ( next!=0 ) next->Save_Link(); 00201 } 00202 void Particella::Restore_Link() 00203 { 00204 lf=lfsav; 00205 rg=rgsav; 00206 up=upsav; 00207 dw=dwsav; 00208 cls=0,nata=0; 00209 if ( next!=0 ) next->Restore_Link(); 00210 } 00211 //============================================================== 00212 // U p d a t e _ D e v s t o r y 00213 //=============================================================== 00214 // salva in formato codificato i devices colpiti dalla particella. 00215 // il bit acceso corrisponde al device colpito 00216 // attenzione memorizza solo i primi 64 device do offset in poi. 00217 void Particella:: 00218 Update_Devstory(int idev) { 00219 static int offset=-1; 00220 if (offset==-1) { 00221 offset=0; 00222 if (collo!=0) offset=collo->idev; 00223 else if (xch02!=0) offset=xch02->idev; 00224 else return; 00225 } 00226 if (offset<1) return; 00227 unsigned long long bit_uno=1; 00228 int shift= idev-offset; 00229 if (shift>-1&&shift<64) 00230 devstory = (devstory|(bit_uno<<shift)); 00231 return; 00232 } 00233 //================================================================ 00234 // R e s e t _ stato 00235 //================================================================= 00236 00237 void Particella:: 00238 Reset_Stato() 00239 { 00240 // start from the tree top..... 00241 00242 00243 // Gout<<"\n Reset "<<nome <<" id "<<id ; 00244 fato = Undef; 00245 nata=0; 00246 devhit=devstory=Ifato=0; 00247 P.Riposo(); 00248 Gp.Riposo(); 00249 X.Reset(); 00250 Gx.Reset(); 00251 if ( Pair_Production>0 ) Pair_Production=1; 00252 if ( Brems_Production>0 ) Brems_Production=1; 00253 pathok=path_max=path_done=last_path=0.0; 00254 cstar=10.; // flag esplicitamente voluta...vedi Voldec... 00255 if ( next!=0 ) next->Reset_Stato(); //iterate attenzione meglio di no!!!! 00256 00257 } 00258 00259 00260 00261 //=============================================================== 00262 // R i c e r c a 00263 //============================================================== 00264 Particella *Particella:: 00265 Ptr_Particle ( const char *pp ) 00266 // attenzione va bene solo per MakeList... 00267 // cerca la particella di nome pp tra le particelle della lista già create... 00268 { 00269 Particella *ptr; 00270 ptr = this; 00271 while ( ptr != 0 ) 00272 { 00273 if ( pp == ptr->nome && ptr->dw == 0 ) 00274 return ptr; // si! 00275 ptr = ptr->next; 00276 } 00277 return ptr; // no! return 0 00278 00279 } 00280 00281 //============================================================== 00282 Particella *Particella:: 00283 Get_Pointer ( char *pp ) 00284 { 00285 // con procedura iterativa....attenzione va bene solo per MakeList... 00286 // o la dove viene chiamata poche volte per run... 00287 // altrimenti mangia spazio memoria...... 00288 if ( pp==nome ) return this; 00289 if ( next!=0 ) return Get_Pointer ( pp ); 00290 return 0; 00291 } 00292 00293 //================================================================ 00294 // S t a m p a q u e s t a p a r t i c e l l a 00295 //================================================================= 00296 void Particella:: 00297 Stampa_questa_particella () 00298 { 00299 // Gout<<"\n Ev "<< Eventi_Fatti<<" Stampa part num: "<<id; 00300 if ( nome==Dlz && dw == 0 ) 00301 { 00302 Gout<<"\n Dalitz pair no electrons linking.. stop"<<std::endl; 00303 exit ( 0 ); 00304 } 00305 00306 // P.print(nome); 00307 Gout<<"\n "<<setw ( 4 ) <<ido<<" <"<<setw ( 3 ) <<idm<<"> "<<setw ( 8 ) <<id<<" " 00308 <<setw ( 5 ) <<nome<<" ["<<setw ( 6 ) <<fato<<" "<<Ifato<<"] Type: "<<setw ( 6 ) <<type; 00309 00310 00311 if ( dw != 0 ) 00312 { 00313 Gout<<" ==> dw-> "<<setw ( 8 ) <<dw->id<<" <" 00314 <<setw ( 3 ) <<dw->idm<<"> " 00315 <<setw ( 5 ) <<dw->nome<<" "<<setw ( 7 ) <<dw->fato<<" "; 00316 if ( dw->rg != 0 ) 00317 Gout<<" + "<<setw ( 5 ) <<dw->rg->nome<<" "<<setw ( 7 ) <<dw->rg->fato<<" " 00318 <<setw ( 8 ) <<dw->rg->id<<" <" 00319 <<setw ( 3 ) <<dw->rg->idm<<">"; 00320 } 00321 00322 if ( rg!=0 && type==Bullet) 00323 Gout<<" ==> urta-> "<<setw ( 9 ) <<rg->id<<" <" 00324 <<setw ( 3 ) <<rg->idm<<"> " 00325 <<setw ( 4 ) <<rg->nome<<" "<<setw ( 7 ) <<rg->fato; 00326 00327 if ( cls!=0 ) 00328 Gout<<" ==> Cls-> "<<setw ( 9 ) <<cls->id<<" <" 00329 <<setw ( 3 ) <<cls->idm<<"> " 00330 <<setw ( 4 ) <<cls->nome<<" "<<setw ( 7 ) <<cls->fato; 00331 } 00332 00333 //================================================================ 00334 // S t a m p a p a r t i c e l l e 00335 //================================================================= 00336 00337 void Particella:: 00338 Stampa_particle ( Reazione *rea ) 00339 { 00340 //iterative method attenzione usare con parsimonia!!!! 00341 00342 if ( this==rea->avo ) 00343 Gout<<"\n\n ido idm id nom stato stampa Ev "<<evento_.Gen.Event; 00344 Stampa_questa_particella(); 00345 // iterate.... 00346 if ( dw!=0 ) 00347 { 00348 dw->Stampa_particle ( rea ); 00349 if ( dw->rg!=0 ) dw->rg->Stampa_particle ( rea ); 00350 } 00351 if ( cls!=0 ) cls->Stampa_particle ( rea ); 00352 if (type==Bullet&&rg!=0) rg->Stampa_particle ( rea ); 00353 00354 return; 00355 } 00356 00357 00358 00359 00360 //================================================================ 00361 00362 // redefine the particle id 00363 void Particella:: 00364 Set_Id() 00365 { 00366 // The reaction is described as chain of two bodies 00367 // decay. 00368 // The ID is usefull to undertand the particle position. 00369 // 00370 // It is defined as: id = xxx.p.ll: 00371 // ll= the decay order or the generation level. 00372 // p = 0 is the right particle in the deacy,p = 1 to theleft, p = 3 ( cls) particle belongin to a cluster (see gasint) 00373 // xxx = ido generation number of the mother pareticle 00374 // so: ID = ll+100*p+1000*xxx 00375 00376 if ( up!=0 ) { 00377 id=(up->id%100)+1+1000*up->ido; 00378 00379 if (lf!=0 ) 00380 { 00381 if (type!=Bers)id+=100; 00382 else id+=400; 00383 } 00384 else if (up->cls==this )id+=300; 00385 00386 } 00387 else id=0; 00388 00389 } 00390 00391 //============================================================= 00392 // D e b u g _ o u t 00393 //============================================================== 00394 // printout for events debug Debug_out 00395 void Particella::Debug_out () 00396 { 00397 Particella *pr; 00398 Device *pv; 00399 pr = this; 00400 00401 Gout<<"\n\n Ev " 00402 <<setprecision ( 2 ) <<fixed 00403 <<setw ( 7 ) << evento_.Gen.Event<<" time=" 00404 <<setw ( 6 ) <<TBurst->Get_Tempo() <<" tl=" 00405 <<setw ( 6 ) <<TBurst->Get_Tlast() <<" " 00406 <<setw ( 3 ) << pr->id<<" <" 00407 <<setw ( 3 ) <<pr->idm<<"> " 00408 <<setw ( 25 ) <<pr->rea_madre->Get_Titolo(); 00409 00410 TBurst->Reset_Tlast(); 00411 while ( pr != 0 ) 00412 { 00413 if ( pr->fato != Undef ) 00414 { 00415 Gout<<"\n " 00416 <<setprecision ( 2 ) <<fixed<<" P=(" 00417 <<setw ( 7 ) << pr->P[0]<<" " 00418 <<setw ( 7 ) << pr->P[1]<<" " 00419 <<setw ( 8 ) << pr->P[2]<<") E=" 00420 <<setw ( 6 ) << pr->P[3]<<" Fato: " 00421 <<setw ( 6 ) << pr->fato; 00422 Gout<<"\n Gp=(" 00423 <<setw ( 7 ) << pr->Gp[0]<<" " 00424 <<setw ( 7 ) << pr->Gp[1]<<" " 00425 <<setw ( 8 ) << pr->Gp[2]<<") "<<pr->Get_Nome(); 00426 Gout<<"\n Gx=(" 00427 <<setw ( 7 ) << pr->Gx[0]<<" " 00428 <<setw ( 7 ) << pr->Gx[1]<<" " 00429 <<setw ( 8 ) << pr->Gx[2]<<")"; 00430 Gout<<"\n x =(" 00431 <<setw ( 7 ) << pr->X[0]<<" " 00432 <<setw ( 7 ) << pr->X[1]<<" " 00433 <<setw ( 8 ) << pr->X[2]<<") Path_done: " 00434 <<setw ( 8 ) <<pr->path_done<<std::endl; 00435 } 00436 00437 // if(pr->nome==Res) resmas=pr->massa; 00438 pr = pr->next; 00439 } 00440 double energia=0.0; 00441 pv = Apparato; 00442 while ( pv != 0 ) 00443 { 00444 energia+=pv->eDev; 00445 // Gout<<"\n %s %8.3lf", pv->nome,pv->eDev); 00446 pv=pv->next; 00447 } 00448 Gout<<"\n Tot E seen ="<<energia; 00449 Gout<<"\n ----gmp----- ------- ------\n"<<std::endl; 00450 return; 00451 } 00452 00454 // V o l d e c 00455 //============================================================= 00456 // Decay in flight of pa in pb and pc Voldec 00457 //------------------------------------------------------------- 00458 00459 int Particella:: 00460 Voldec ( Particella * pb, Particella * pc ) 00461 00462 { 00463 Particella *pa; 00464 double eb, pcm,pt,pcmq; 00465 double rma, rmb, rmc; 00466 double cost,fi, sinfi, cosfi; 00467 static qvet Stesso; //dummy for lorentz buster... 00468 //============ 00469 00470 pa = this; // nota giusto per differenziare rispetto a pb e pc 00471 if ( pa ->fato==Decay ); // particelle che decadono 00472 else if ( pa->ctau < 0. ) 00473 return -1; // stable particle. no action is taken*/ 00474 00475 // Test the fato of the father particle, if not normal */ 00476 // stop the child generation */ 00477 // Gout<<"\n voldec "<<nome; 00478 00479 00480 if ( pa->fato != Nata && pa->fato != Decay ) 00481 { 00482 pb->fato = Undef; 00483 pb->Ifato=0; 00484 pc->fato = Undef; 00485 pc->Ifato=0; 00486 pc->X = pb->X = pa->X; 00487 return -2; //non va trasportato! 00488 } 00489 // copia P nel vettore ausiliario Qpatre, può essere alterato da DecParm 00490 pa->Qpatre=pa->P; 00491 00492 00493 //----------------------------------------------------------- 00494 // produzione coppie nella interazione dei gamma nel materiale... 00495 // produzione bremsstrhalung da leptoni... 00496 00497 if ( pa->Pair_Production>1 ) pa->DecParm_Pair(); 00498 if ( pa->Brems_Production>1 ) pa->DecParm_Brems(); 00499 00500 pb->fato = Nata; 00501 pb->Ifato = -1; 00502 pc->fato = Nata; 00503 pc->Ifato = -1; 00504 00505 // get the parameters for particle : FaseSpace resonance == dec isotropici, 00506 // coppia dalitz, ... munu da K3l... 00507 // does nothing for stable particles .... 00508 pb->DecParm(); 00509 pc->DecParm(); 00510 00511 00512 // define the particles parameters for next use 00513 rma = Qpatre.m; 00514 rmb = pb->massa; 00515 rmc = pc->massa; 00516 00517 pb->P[3] = eb = ( rma * rma + rmb * rmb - rmc * rmc ) * 0.5 / rma; 00518 pc->P[3] = rma - eb; 00519 pcm = sqrt ( ( pcmq= ( eb + rmb ) * ( eb - rmb ) ) ); 00520 pb->P.normaq = pc->P.normaq = pcmq; 00521 pb->P.norma = pc->P.norma = pcm; 00522 00523 //******************************************************************/ 00524 // decdimento isotropo se cstar non e' stato gia' definito! 00525 if ( pb->cstar>1. ) // decadimento non definito: genero isotropico 00526 { 00527 cost = 1.0 - 2.0 * Pran(); 00528 fi = DuePiGreco* Pran(); 00529 cosfi = cos ( fi ); 00530 sinfi = sin ( fi ); 00531 } 00532 else // fisica di decadimento definita 00533 { 00534 cost = pb->cstar; 00535 fi = pb->fistar; 00536 cosfi = cos ( fi ); 00537 sinfi = sin ( fi ); 00538 } 00539 // Gout<<"\n Voldec ev2 "<<Eventi_Fatti<<" "<<this<<" "<<pb <<" "<<pc<<flush; 00540 // Gout<<" "<<this->Get_Nome()<<" "<<pb->Get_Nome() <<" "<<pc->Get_Nome()<<flush; 00541 // Definisco un sistema con l'asse z nella direzione di moto 00542 // della particella padre nel baricentro dove fu creata. 00543 // Come creare l'asse x! adesso a random!! 00544 00545 // Attenzione Pbar va definito cosi' se si tratta di risonanza 00546 // altrimenti occorre Pbar=pa->P vedere meglio!!!!!!!!!!! 00547 gvet vaz=pa->Pbar.Verso(); // asse z 00548 // definizione del miglior asse sghembo a vaz.. arbitrario 00549 gvet vzn ( 1.,0.,0. ); 00550 // attenzione rivedere anche se funziona !!!!!!!!!!!!! 00551 double ax,ay,az; 00552 vaz.putv( ax,ay,az ); 00553 ax=fabs ( ax ); 00554 ay=fabs ( ay ); 00555 az=fabs ( az ); 00556 if ( ay<=az&&ay<=ax ) vzn.setv ( 0.,1.,0. ); 00557 else if ( az<=ax ) vzn.setv ( 0.,0.,1. ); 00558 //------- 00559 gvet vay=vaz&vzn; 00560 vay.Norma(); 00561 vay=vay.Verso(); // asse y 00562 gvet vax=vay&vaz; 00563 vax.Norma(); 00564 vax=vax.Verso(); // asse x 00565 pt = pcm * ( sqrt ( 1. - cost * cost ) );// pericolo di negativa sqrt! 00566 gvet mom ( vax*pt*cosfi + vay*pt*sinfi + vaz*pcm*cost ); 00567 // mom.Norma(); 00568 // mom.print("mom"); 00569 00570 pc->P[0]=- ( pb->P[0]=mom[0] ); 00571 pc->P[1]=- ( pb->P[1]=mom[1] ); 00572 pc->P[2]=- ( pb->P[2]=mom[2] ); 00573 00574 00575 00576 //ricordo il suo momento nel baricentro. 00577 pb->Pbar=pb->P; 00578 pc->Pbar=pc->P; 00579 00580 00581 00582 pb->Pburst=Qpatre; 00583 pc->Pburst=Qpatre; // ricordo il momento del padre ... 00584 // vedi qui sotto.. si evitano problemi con le trasformate di lrentz .. 00585 00586 00587 00588 00589 00590 //Get the lorentz booster 00591 00592 00593 00594 if ( pa->type==Res ) // decadim in 3 or 4 bodies via Res.... 00595 // pa->nome==Pic2 ,Pi02,P00p,Gg2 00596 { 00597 // prima un burst nella direzione e velocità che aveva la Pa 00598 // nel baricentro di suo padre 00599 pb->P=pb->P.Lburst ( pa->Pbar ); 00600 pc->P=pc->P.Lburst ( Stesso ); //sono nel bar del padre della risonanza 00601 00602 00603 // quindi passo al lab con il burst impresso a Pa a suo tempo 00604 pb->P=pb->P.Lburst ( pa->Pburst ); 00605 pc->P=pc->P.Lburst ( Stesso ); 00606 } 00607 00608 // se il padre non e' una risonanza passo direttamente al lab if pa moves * 00609 00610 else if ( Qpatre.norma > 0.0 ) 00611 { 00612 pb->P=pb->P.Lburst ( Qpatre ); 00613 pc->P=pc->P.Lburst ( Stesso ); 00614 00615 00616 } 00617 //------------------------------------- 00618 00619 00620 00621 pb->Gp = pb->P; 00622 pc->Gp = pc->P; 00623 00624 pb->Vers=pb->P.Verso(); 00625 pc->Vers=pc->P.Verso(); 00626 // nascita set to ok... 00627 pb->nata=pc->nata=1; 00628 // define the initial coordinates at the father space point */ 00629 // see the Transport routine */ 00630 pb->Gx=pb->X = pc->Gx= pc->X = pa->X; 00631 00632 /******************* debug ***/ 00633 if ( Debugon==1 ) 00634 // if (Eventi_Fatti==129) 00635 { 00636 // pa->Stampa_questa_particella(); 00637 00638 pa->P.print ("Pa_p"); 00639 pa->X.print ("Pa_X"); 00640 Gout<<" "<<setw(8)<<pa->nome <<" "<<setw(4)<<pa->ido<<" "<<setw(4)<<pa->id <<" Ev "<<Eventi_Fatti; 00641 pb->P.print ("Pb_p"); 00642 pb->X.print ("Pb_X"); 00643 Gout<<" "<<setw(8)<<pb->nome <<" "<<setw(4)<<pb->ido<<" "<<setw(4)<<pb->id; 00644 pc->P.print ("Pc_p"); 00645 pc->X.print ("Pc_X"); 00646 Gout<<" "<<setw(8)<<pc->nome <<" "<<setw(4)<<pc->ido<<" "<<setw(4)<<pc->id; 00647 Gout<<endl; 00648 } 00649 00650 /************ end debug ********/ 00651 return 1; 00652 } 00653 00654 00655 //============================================================= 00656 // T R A S P O R T 00657 //============================================================= 00703 int Particella:: 00704 Trasport () 00705 { 00706 00707 int botta = 0, loop = 1000; 00708 00709 00710 00711 // do nothing if ..... 00712 if ( P.norma == 0.0 || ctau == 0.0 || ( fato != Nata ) ) return botta; 00713 00714 00715 // Gout<<"\n Entro in Transport "<<evento_.Gen.Event; 00716 // Gout<<"\n Trsa: "<<setprecision(2) 00717 // <<" Ev "<<evento_.Gen.Event<<" id "<< id<<" "<<fato<<" P "<<P.norma<<" ctau "<<ctau<<" see "<<see; 00718 00719 00720 00721 if ( see == 0 ) { 00722 fato = Novede; 00723 Ifato=-10; 00724 return botta; 00725 } 00726 00727 double lontano=Zona - X[2]; 00728 00729 // Gout<<"\nEv "<<Eventi_Fatti<<" Trans. " <<nome<<" "<< ido<< " " <<type; 00730 // if(dw!=0) Gout<< " "<<dw->nome; 00731 00732 if ( type != Beam && type!=Bullet) 00733 { 00734 if ( ctau > 0.0 ) // particella che decade seguita da .....anche nulla.. 00735 { 00736 double volo = ctau * P.norma / massa; 00737 path_max = -volo * log ( EPSI + Pran() ); 00738 if ( path_max> lontano ) path_max = lontano; 00739 00740 // if(Eventi_Fatti>71&Eventi_Fatti<91) 00741 // Gout<<"\nEv "<<setw(8)<<Eventi_Fatti<<" Trans. "<<setw(6)<<nome<<" "<<setw(5)<< ido<<setprecision(2) 00742 // <<" "<<setw(9)<< path_max<<" pz "<<setw(9)<<P.z<<" Rand "<<setw(9)<<Pran()<<flush; 00743 } 00744 else path_max = lontano; // for stable particles...or with decay not defined... 00745 00746 00747 } 00748 00749 // Gout<<"\nEv "<<Eventi_Fatti<<" Trans. "<<nome<<" " << path_max<<" pz "<<P.z; 00750 // set the devices accessible to the flighing particle.. 00751 00752 Set_Rivela_in_Dev ( this ); 00753 // Apparato->Set_Rivela(this); 00754 //===================================================== 00755 //===================================================== 00756 // start the loop on the apparatus 00757 00758 // Vers = flight direction defined in particle object.... 00759 00760 path_done = pathok = 0.0; 00761 Device *pv,*Dvok; 00762 Devloop = Apparato; 00763 Apparato->Reset_Pos(); 00764 00765 while ( --loop >= 0 ) 00766 { 00767 pv=Devloop; // starting Dev... can be changed by Get_camm. 00768 // if(idm>4&&idm<9) 00769 // Gout<<"\n Ev "<<setw(5)<<Eventi_Fatti<< " "<<setw(8)<<nome << " "<<setw(8)<<pv->nome; 00770 00771 Dvok=pv->Get_camm ( this ); 00772 00773 if ( Dvok == 0 ) break; //end transport: passati tutti i dev... 00774 pathok=Dvok->camm; 00775 00776 // if(Dvok->idev==2&&ido==1) 00777 // Gout<<"\n Ev "<<setw(5)<<Eventi_Fatti<< " "<<setw(8)<<nome << " devloop "<<setw(8)<<pv->nome 00778 // << " devok "<<setw(8)<<Dvok->nome<<" " <<setw(8)<<Dvok->camm<< " "<<Dvok->nowpos; 00779 00780 00781 /* 00782 if(Dvok->idev==2&&ido==1) 00783 cout<<"\n Ev "<<setw(5)<<Eventi_Fatti<< " "<<setw(8)<<nome 00784 << " "<<setw(8)<<Dvok->nome<<" pth "<<setw(8)<<pathok 00785 << " pos "<<setw(2)<<Dvok->nowpos<<" prev "<<setw(8)<<Dvok->prevpos;*/ 00786 00787 00788 // potential path redefined if bigger then dacay path. 00789 if ( ctau>0.0 && pathok > ( path_max-path_done ) ) 00790 { 00791 pathok= ( path_max-path_done+0.000001 ); 00792 fato=Decay; 00793 Ifato=-2; 00794 00795 00796 /* 00797 if ( this==SelRea->avo && Dvok->fun==Gasint ) 00798 { 00799 MkCluster(); fato=Gasint; Ifato=-20; //Qui si crea un cluster..... 00800 Gout<<"\n Ev0 "<<evento_.Gen.Event<<" "<<nome 00801 <<" in "<<Dvok->nome 00802 <<" "<<fato 00803 <<" path "<<setw ( 8 ) << pathok 00804 << " Z "<<setw ( 8 ) << X.z; 00805 00806 } 00807 */ 00808 00809 } 00810 00811 00812 00813 00814 00815 //============================================================================== 00816 //============================================================================== 00817 00818 if ( Dvok->nowpos == ESTERNO ); // do nothing 00819 00820 00821 //============================================================================== 00822 //============================================================================== 00823 00824 00825 else if ( Dvok->nowpos == INTERNO ) 00826 00827 { 00828 00829 botta++; 00830 00831 // if ( idm==14 ) Spia ( "Interno",pv,Dvok,47,52 ); 00832 00833 //---------------------------------------------------- 00834 //---------------------------------------------------- 00835 00836 // destino secondo la funzione 00837 00838 if ( Dvok->fun == Trig || 00839 Dvok->fun == None || 00840 Dvok->fun == Nodef ); // nessuna decisione .. si continua a tracciare 00841 00842 // altrimenti le cause per terminare il tracing...si cambia il fato 00843 00844 else if ( Dvok->fun == Dead || 00845 Dvok->fun == Trigh ) { 00846 fato = Dvok->nome; 00847 Ifato=Dvok->idev; 00848 } 00849 00850 if ( Dvok->rivela==2|| // assorbe tutta l'energia e muore 00851 Dvok->rivela==4 ) { 00852 fato = Dvok->nome; 00853 Ifato=Dvok->idev; 00854 } 00855 00856 else if ( Dvok->fun == Magn || Dvok->fun == Dump ) 00857 { 00858 // nota il frame del magnete (che corrisponde all' INTERNO) fa da dump. Il campo è sempre nel "buco" 00859 if ( nome!=Mum && nome!=Mup ) //except the muons.. 00860 { 00861 fato = Dvok->nome; 00862 Ifato=Dvok->idev; 00863 } 00864 } 00865 00866 else if ( Dvok->fun == Veto ) 00867 { 00868 // nel caso del "veto" si uccide addirittura l'evento con il flag botta =-1000 00869 // invece si termina solo il tracing della particella se si vuole scrivere tutto 00870 if ( WrtNt!=WRTALL ) 00871 { 00872 fato = Dvok->nome; 00873 Ifato=Dvok->idev; 00874 botta=-1000; 00875 } 00876 else { 00877 fato = Dvok->nome; 00878 Ifato=Dvok->idev; 00879 } 00880 } 00881 // debug quale decisione? 00882 /* 00883 if ( Dvok->idev==2 ) 00884 { 00885 X.print ( "X1" ); 00886 Gout<<setprecision(3) 00887 <<" ev "<< Eventi_Fatti<<" "<< nome 00888 <<" pos " <<Dvok->nowpos<<" "<<Dvok->prevpos 00889 <<" dh "<<devhit 00890 <<" ft "<<fato 00891 << " pathok " <<setw(9)<<pathok; 00892 } 00893 */ 00894 //---------------------------------------------------- 00895 //---------------------------------------------------- 00896 // scrivo i colpi (cioè memorizza gli hits nei devices) quando 00897 00898 if ( Dvok->prevpos==ESTERNO || // è appena entrata dall'esterno 00899 Dvok->prevpos==INBUCO || // è entrata dal "buco" 00900 Dvok->prevpos>=UNDEF || // appena nata o devhit=0 (vedi ScrvColpi() ) 00901 devhit==0 ) Dvok->ScrvColpi ( this ); // prima volta vista 00902 00903 00904 } 00905 // ---------- fine interno ----------- 00906 //============================================================================== 00907 //============================================================================== 00908 //------------ E' nel buco 00909 else if ( Dvok->nowpos == INBUCO ) 00910 { 00911 if ( Dvok->fun==Magn && // entra nel "buco" del mag o nasce nel mag! 00912 ( devhit==0 || 00913 Dvok->prevpos==UNDEF|| 00914 Dvok->prevpos==ESTERNO ) ) { 00915 Dvok->ScrvColpi ( this ); 00916 } 00917 00918 //pro memoria ...dall'INTERNO va nel buco..per ora si lascia tracciare 00919 //if ( Dvok->prevpos== INTERNO ); 00920 00921 } 00922 //--------Fine in buco------------ 00923 //============================================================================== 00924 //============================================================================== 00925 //.... check the fato 00926 00927 if ( fato!=Nata&&fato!=Decay ) 00928 { 00929 return botta; //stop tracking....se il fato è diverso da normale o da "decay" 00930 } 00931 // qui solo per particelle con fato normale o in decadimento. 00932 //*************************************************************************** 00933 //----------------------------- real trasport ------------------------------- 00934 // now move the particle in the space doing also 00935 // pair production or bremsstrhalung .or clusters..or move in magnetic field..and multiplescattering. 00936 // 00937 00938 00939 if (Dvok->nowpos == ESTERNO) 00940 { 00941 // free flight 00942 00943 Move ( pathok ); 00944 last_path=pathok; 00945 } 00946 else 00947 { 00948 int ift=0; 00949 if ( ( ift=Dvok->Traccia ( this )) > 0 ) // muore nel tracing ... 00950 { 00951 fato=Dvok->nome; 00952 Ifato=Dvok->idev; 00953 return botta; 00954 } 00955 else if (ift < 0 ) // muore nel tracing ... 00956 { 00957 fato=Dvok->nome; 00958 Ifato=ift; 00959 return botta; 00960 } 00961 00962 00963 00964 } 00965 00966 //============================================================================== 00967 //============================================================================== 00968 if ( fato==Decay ) //stop tracking....anche per gam->pair prod and brems ... 00969 { 00970 if ( X.Norma() >Zona ) { 00971 fato=Decfar; 00972 Ifato=-8; 00973 } 00974 00975 00976 // Si verifica se la particella beam deve fare una interazione con il gas 00977 // attenzione i dev sono annidati.... 00978 00979 if ( this==SelRea->avo && Dvok->nowpos == INBUCO ) //Sono nel buco del dev 00980 { 00981 // quindi guardo se sono anche nel buco del dev Dectubo .... 00982 if ( dectubo!=0 ) 00983 { 00984 if ( dectubo->Posizione() == INBUCO && 00985 dectubo->fun==Gasint ) // attenzione correzione per analisi fondi particolare... 00986 { 00987 // allora genero un cluster da interazione in gas 00988 MkCluster(); 00989 fato=Gasint; 00990 Ifato=-20; //Qui si crea un cluster..... 00991 } 00992 } 00993 } 00994 return botta; 00995 } 00996 if ( P.norma<0.0001 ) // stop tracking per fine energia 00997 { 00998 fato = Dvok->nome; 00999 Ifato=Dvok->idev; 01000 if ( Debugon==1 ) 01001 Gout<<"\nTout2: Ev "<<evento_.Gen.Event<<" "<<nome<<" "<<fato<<" "<<X.z; 01002 return botta; 01003 01004 } 01005 } 01006 //============================================================================== 01007 //============================================================================== 01008 //................ e n d t r a c i n g lo o p ........ 01009 // here if fato == norm ..... rivedere qui.... 01010 01011 if ( ctau < 0.0 ) // particella stabile 01012 { 01013 if ( X.z<.90*Zona ) 01014 { 01015 // X.Norma();X.print(nome); 01016 pathok=path_max-path_done; 01017 X+=Vers*pathok; //transport 01018 // X.Norma();X.print(nome); 01019 } 01020 fato = Lost; 01021 Ifato=-9; 01022 } 01023 01024 // particella che decade...... 01025 else if ( ctau > 0.0 && P.norma>0.001 ) 01026 { 01027 pathok=path_max-path_done; 01028 X+=Vers*pathok; //transport 01029 fato= Decay; 01030 Ifato=-2; 01031 01032 if ( X.Norma() >Zona ) 01033 { 01034 fato=Decfar; 01035 Ifato=-8; 01036 } 01037 } 01038 return ( botta ); 01039 } 01040 //==================================== 01041 void Particella::Move ( double passo ) 01042 { 01043 // move free along remaining tratto 01044 X+=Vers*passo; 01045 X.Norma(); 01046 path_done+=passo; 01047 } 01048 01049 //================================================================ 01050 // S p i a 01051 //================================================================= 01052 01053 void Particella::Spia ( char * tit, Device *stdev, Device * loopdev,int start,int stop ) 01054 { 01055 if ( loopdev->idev<start|| loopdev->idev>stop ) return; 01056 Gout.setf ( ios::fixed,ios::floatfield ); 01057 Gout<<setprecision ( 2 ); 01058 Gout<<"\n Trans "<<tit<<" "<<evento_.Gen.Event 01059 <<" StartDev: "<<setw ( 10 ) <<stdev->nome 01060 <<" at z"<<setw ( 8 ) << stdev->Cface.z 01061 <<" "<<nome<<" at Z "<< X.z 01062 << " Path "<<setw ( 8 ) <<path_max 01063 << " fatto "<<setw ( 8 ) <<path_done 01064 <<" in "<<setw ( 8 ) <<loopdev->nome 01065 <<" at z"<<setw ( 8 ) << loopdev->Cface.z 01066 <<" prev " <<setw ( 8 ) <<loopdev->prevpos 01067 <<" nowpos " <<setw ( 8 ) <<loopdev->nowpos 01068 << " pathok "<<setw ( 8 ) <<pathok; 01069 01070 }