FlyoDoc_2011 Pisa 2011 by GmP --- 011
|
00001 /*************************************************************************** 00002 GPmrg->h - description 00003 ------------------- 00004 revised : Febbraio agosto 2009 <=========== 00005 copyright : (C) 2000 by Giuseppe M Pierazzini 00006 email : pierazzini@unipi.it 00007 ***************************************************************************/ 00008 //---------------------- vector ----------------------------- 00009 #define GVECTOR 00010 #include "parm.h" 00011 #include "gvet.h" 00012 #include "gmatrix.h" 00013 using namespace std; 00014 //------------------------------------------------------ 00015 //-------------------------------------------------------- 00016 // note precision bits: double 53 bits, float 24 bits 00017 00018 00019 double normaux; 00020 // costruttori 00021 // vedi gevet.h 00022 //====== 00023 00024 00025 //==================================================== 00026 // Definisco gli operatori dell'algebra tra vettori 00027 // attenzione mettere le parentesi per le priorita' 00028 // si usano i registri per permettere operazioni 00029 // complesse sulla stessa linea e con migliore utilizzazione 00030 // della memoria. 00031 //---------------------------------------------------- 00032 00033 // operatore unario di cambio segno 00034 gvet gvet::operator-() 00035 { 00036 gvet temp; 00037 temp.x=-x; 00038 temp.y=-y; 00039 temp.z=-z; 00040 temp.norma=norma; 00041 temp.normaq=normaq; 00042 return temp; 00043 } 00044 00045 gvet gvet::operator* ( const double a ) 00046 { 00047 gvet temp; 00048 temp.x=x*a; 00049 temp.y=y*a; 00050 temp.z=z*a; 00051 temp.norma=norma*fabs ( a ); 00052 temp.normaq=temp.norma*temp.norma; 00053 return temp; 00054 } 00055 00056 // ritorna il vettore normalizzato sul piano xz 00057 gvet gvet::NxzVerso() 00058 { 00059 gvet temp; 00060 normaux=sqrt ( x*x+z*z ); 00061 temp.x=x/normaux; 00062 temp.y=0. ; 00063 temp.z=z/normaux; 00064 temp.norma=temp.normaq=1.0; 00065 return temp; 00066 } 00067 // ritorna il vettore normalizzato sul piano yz 00068 gvet gvet::NyzVerso() 00069 { 00070 gvet temp; 00071 normaux=sqrt ( y*y+z*z ); 00072 temp.x=0.; 00073 temp.y=y/normaux; 00074 temp.z=z/normaux; 00075 temp.norma=temp.normaq=1.0; 00076 return temp; 00077 } 00078 // somma di due vetori V1+V2 or dif 00079 gvet gvet::operator+ ( const gvet& a ) 00080 { 00081 gvet temp; 00082 temp.x=x+a.x; 00083 temp.y=y+a.y; 00084 temp.z=z+a.z; 00085 temp.Norma(); 00086 return temp; 00087 } 00088 gvet gvet::operator- ( const gvet& a ) 00089 { 00090 gvet temp; 00091 temp.x=x-a.x; 00092 temp.y=y-a.y; 00093 temp.z=z-a.z; 00094 temp.Norma(); 00095 return temp; 00096 } 00097 // prodotto vettoriale V1 esterno V2 00098 gvet gvet::operator& ( const gvet& b ) 00099 { 00100 gvet temp; 00101 temp.x=y*b.z-z*b.y; 00102 temp.y=z*b.x-x*b.z; 00103 temp.z=x*b.y-y*b.x; 00104 temp.Norma(); 00105 return temp; 00106 } 00107 00108 00109 gmatrix& gvet::operator >> (gmatrix & M ) 00110 { 00111 //crea il tensore |this><this| 00112 M.Proj(*this); 00113 return M; 00114 } 00115 00116 gvet & gvet::operator = (gmatrix & M ) 00117 00118 { 00119 // restituisce in this il vettore colonna 0 della matrice M. 00120 M.Get_Vcol (*this); 00121 return *this; 00122 } 00123 00124 00125 //---------------- output --------------- 00126 // output per debug............... 00127 void gvet::print ( const char *t ) 00128 { 00129 Gout.setf ( ios::right,ios::adjustfield ); 00130 Gout<<std::setfill ( ' ' ); 00131 Gout<<std::setprecision ( 3 ) <<fixed; 00132 Gout<<"\n"<<setw ( 7 ) <<t<<"=[" 00133 <<setw ( 9 ) <<x<<" " 00134 <<setw ( 9 ) <<y<<" " 00135 <<setw ( 9 ) <<z<<" ]" <<" |" 00136 <<setw ( 9 ) <<norma<<"|"; 00137 Gout.setf ( ios::floatfield ); 00138 00139 } 00140 00141 void gvet::print ( long ev,const char *pnome,int pid,const char *devnome ) 00142 { 00143 Gout.setf ( ios::right,ios::adjustfield ); 00144 Gout<<std::setfill ( ' ' ); 00145 Gout<<std::setprecision ( 2 ) <<fixed; 00146 Gout<<"\n"<<setw ( 7 ) <<ev 00147 <<" "<<setw ( 5 ) <<pnome<< " "<<setw ( 3 ) <<pid 00148 <<" "<<setw ( 5 ) <<devnome <<"=[" 00149 <<setw ( 9 ) <<x<<" " 00150 <<setw ( 9 ) <<y<<" " 00151 <<setw ( 11 ) <<z<<" ]| " 00152 <<setw ( 9 ) <<norma<<" | "; 00153 Gout.setf ( ios::floatfield ); 00154 } 00155 00156 00157 00158 00159 //------------------------------------------------------------ 00160 //============================================================ 00161 //------------------------------------------------------------ 00163 00164 qvet::qvet ( double massa ) 00165 { 00166 x=0.0; 00167 y=0.0; 00168 z=0.0; 00169 m=massa; 00170 mq=m*m; 00171 Energia(); 00172 Norma(); 00173 } 00174 // attenzione un po'pericoloso.... 00175 qvet::qvet ( double* p ) //da arrey px,py,pz,massa 00176 { 00177 x=p[0]; 00178 y=p[1]; 00179 z=p[2]; 00180 m=p[3]; 00181 mq=m*m; 00182 Energia(); 00183 Norma(); 00184 } 00185 qvet::qvet ( gvet P,double massa ) //da vettore P e massa 00186 { 00187 P.putv( v ); 00188 m=massa; 00189 mq=m*m; 00190 Energia(); 00191 Norma(); 00192 } 00193 00194 00195 qvet::qvet ( double px,double py, double pz, double massa ) 00196 { 00197 x=px; 00198 y=py; 00199 z=pz; 00200 m=massa; 00201 mq=m*m; 00202 Energia(); 00203 Norma(); 00204 } 00205 00206 00207 //==================================================== 00208 // Definisco gli operatori dell'algebra tra vettori. 00209 00210 // double & qvet::operator[](int i) {return v[i];} 00211 00212 00213 // si introducono registri per eseguire senza errori equazioni con piu 00214 // termini del tipo V*c contemporanei 00215 00216 // operatore unario; cambio solo la parte spaziale....!!!! 00217 qvet qvet::operator-() 00218 { 00219 qvet qaux; 00220 qaux.x=-x; 00221 qaux.y=-y; 00222 qaux.z=-z; 00223 qaux.e=e; 00224 qaux.norma=norma; 00225 qaux.normaq=normaq; 00226 qaux.m =m; 00227 qaux.mq=mq; 00228 return qaux;; 00229 } 00230 00231 qvet qvet::operator* ( const double a ) 00232 { 00233 qvet qaux; 00234 qaux.x=x*a; 00235 qaux.y=y*a; 00236 qaux.z=z*a; 00237 qaux.e=e*a; 00238 qaux.norma=norma*a; 00239 qaux.normaq=normaq*a*a; 00240 qaux.m =m*a; 00241 qaux.mq=mq*a*a; 00242 return qaux;; 00243 } 00244 00245 00246 // ricalcola l'invariante relativistico 00247 double qvet::Invar() 00248 { 00249 normaq=x*x+y*y+z*z; norma=sqrt ( normaq ); 00250 mq=e*e - normaq; 00251 if ( mq>0.0 ) m=sqrt ( mq ); else m=-sqrt ( -mq ); //Ritorna la massa negativa!!!! 00252 return m; 00253 } 00254 00255 double qvet::Invarq() 00256 { 00257 normaq=x*x+y*y+z*z; norma=sqrt ( normaq ); 00258 mq=e*e - normaq; 00259 if ( mq>0.0 ) m=sqrt ( mq ); else m=-sqrt ( -mq );//Ritorna la massa negativa!!!! 00260 return mq; 00261 } 00262 00263 00264 00265 // ricalcola l'energia ...a partire dall'impulso e massa 00266 double qvet::Energia() 00267 { 00268 mq=m*m; 00269 normaq=x*x+y*y+z*z; norma=sqrt ( normaq ); 00270 e=sqrt ( mq+normaq ); 00271 return e; 00272 } 00273 // 00274 00275 00276 void qvet::operator= ( double *a ) // attenzione come (px,py,pz,m) 00277 { 00278 x=a[0];y=a[1];z=a[2]; 00279 m=a[3]; 00280 Energia(); 00281 } 00282 00283 qvet & qvet::operator+= ( const qvet& a ) // attenzione non calcola norma.. 00284 { 00285 x+=a.x;y+=a.y;z+=a.z; 00286 e+=a.e; return *this; 00287 } 00288 00289 qvet & qvet::operator-= ( const qvet& a ) // attenzione non calcola norma.. 00290 { 00291 x-=a.x;y-=a.y;z-=a.z; 00292 e-=a.e; return *this; 00293 } 00294 00295 00297 // ricalcola l'impulso ...a partire dall'Energia e massa 00298 // usa come versore di P quello di prima. Attenzione il versore non deve essere nullo. 00299 double qvet::Impulso() 00300 { 00301 double puls=sqrt ( ( e-m ) * ( e+m ) ); 00302 double rnor=puls/sqrt ( x*x+y*y+z*z ); 00303 x= x*rnor; 00304 y= y*rnor; 00305 z= z*rnor; 00306 norma=puls; 00307 normaq=puls*puls; 00308 return norma; 00309 } 00310 00311 00312 // 00313 00314 qvet qvet::operator+ ( const qvet& a ) 00315 { 00316 qvet qaux; 00317 qaux.x=x+a.x; 00318 qaux.y=y+a.y; 00319 qaux.z=z+a.z; 00320 qaux.e=e+a.e; 00321 return qaux;; 00322 } 00323 00324 qvet qvet::operator- ( const qvet& a ) 00325 { 00326 qvet qaux; 00327 qaux.x=x-a.x; 00328 qaux.y=y-a.y; 00329 qaux.z=z-a.z; 00330 qaux.e=e-a.e; 00331 return qaux;; 00332 } 00333 00334 00335 //------------------------------------------------------ 00336 00337 qvet& qvet::Lburst ( qvet & Burst ) 00338 { 00339 static gvet Beta; 00340 static double gam; 00341 // Burst e' un quadrivettore (P,E) relativo alla particella centro di massa. 00342 //se m e' nulla si usano i vecchi valori... 00343 00344 if ( Burst.m>0.0 ) 00345 { 00346 Beta.setvn ( Burst[0]/Burst.e, Burst[1]/Burst.e, Burst[2]/Burst.e ); 00347 gam=Burst.e/Burst.m; 00348 } 00349 // Pnew=(gvet)*this + Beta*(gam*(pb/(1.0+1.0/gam) + e)); // funge perfettamente 00350 // gvet PL=Beta*(Beta%this)/Beta.normaq; 00351 // gvet Pnew=(gvet)*this + PL*(gam-1.) +Beta*(gam*e); 00352 00353 gvet Pnew= ( gvet ) *this + Beta* ( Beta%this ) * ( ( gam-1. ) /Beta.normaq ) +Beta* ( gam*e ); 00354 setvn ( Pnew[0],Pnew[1],Pnew[2],m ); 00355 return *this; 00356 } 00357 00358 00359 // output per debug............... 00360 void qvet::print ( const char *t ) 00361 { 00362 00363 Gout.setf ( ios::right,ios::adjustfield ); 00364 // Gout.setf ( ios::floatfield ); 00365 00366 Gout<<setfill ( ' ' ) <<fixed<<setprecision(2) 00367 <<"\n"<<setw ( 7 ) <<t<<"=[" 00368 <<setw ( 8 ) <<x<<" " 00369 <<setw ( 8 ) <<y<<" " 00370 <<setw ( 9 ) <<z<<" " 00371 <<setw ( 8 ) <<e<<" ] { n=" 00372 <<setw ( 8 ) <<norma<<" " 00373 <<setw ( 8 ) <<normaq<<" m=" 00374 <<setw ( 8 )<<setprecision(3) <<m<<" " 00375 <<setw ( 8 ) <<mq<<"}"<<flush; 00376 00377 } 00378 00379 void qvet::print ( long ev,const char *pnome,int pid,const char *devnome ) 00380 { 00381 Gout.setf ( ios::right,ios::adjustfield ); 00382 Gout<<std::setfill ( ' ' ); 00383 Gout<<std::setprecision ( 2 ) <<fixed; 00384 Gout<<"\n"<<setw ( 7 ) <<ev 00385 <<" "<<setw ( 5 ) <<pnome<< " "<<setw ( 3 ) <<pid 00386 <<" "<<setw ( 5 ) <<devnome <<"=[" 00387 <<setw ( 8 ) <<x<<" " 00388 <<setw ( 8 ) <<y<<" " 00389 <<setw ( 11 ) <<z<<" " 00390 <<setw ( 8 ) <<e<<" ]" <<" |" 00391 <<setw ( 8 ) <<norma<<"| " 00392 <<setw ( 8 ) <<normaq<<"| " 00393 <<setw ( 8 ) <<m<<"| " 00394 <<setw ( 8 ) <<m<<flush; 00395 Gout.setf ( ios::floatfield ); 00396 } 00397 00398