ANALYSIS/FIN_PHYS.h

00001 // @(#)fROOT/PREAN:$Name:  $:$Id: FIN_PHYS.h,v 1.5 2007/09/25 14:51:51 Diego_Faso Exp $
00002 // Author: Diego Faso <mailto:faso@to.infn.it>, 2006/11/09
00003 
00004 #ifndef FROOT_FIN_PHYS
00005 #define FROOT_FIN_PHYS
00006 
00008 // The FINUDA physics namespace //
00010 
00011 #include <TString.h>
00012 #include <TMath.h>
00013 #include <TROOT.h>
00014 
00015 namespace FIN_PHYS {
00016 
00017   enum E_FndDataTaking {
00018     DTAK_2003_2004 = 0, 
00019     DTAK_2006_2007 = 1, 
00020   };
00021 
00022   enum E_FndFidaVersion {
00023     FIDAVER_521 = 0, 
00024     FIDAVER_601 = 1, // version 600 has been skipped
00025     FIDAVER_603 = 2, // version 602 has been skipped (development version)
00026     FIDAVER_END = 3, // used for arrays
00027   };
00028 
00029   enum E_FinPhys_BhabhaPart_ID{ // negative particles at id=0
00030     FPh_BhaElec_id = 0,
00031     FPh_BhaPosit_id = 1,
00032   };
00033 
00034   enum E_FinPhys_HypePart_ID{ // negative particles at id=0
00035     FPh_HypKmin_id = 0,
00036     FPh_HypKplu_id = 1,
00037   };
00038   
00039   enum E_Fnd_PID { // summary of Particle ID codes (geant convention)
00040     FPh_PID_Positron =     2, // -11 (PDG number)  
00041     FPh_PID_Electron =     3, //  11
00042     //
00043     FPh_PID_Muon_plu =     5, // -13  
00044     FPh_PID_Muon_min =     6, // 13   
00045     //
00046     FPh_PID_Pi_zero =  7, //  111   
00047     FPh_PID_Pi_plu  =  8, //  211   
00048     FPh_PID_Pi_min  =  9, // -211  
00049     //
00050     FPh_PID_Kaon_Long  =    10, // 130   
00051     FPh_PID_Kaon_Short =    16, // 310,   
00052     FPh_PID_Kaon_plu   =   11, // 321  
00053     FPh_PID_Kaon_min   =   12, // -321
00054     //
00055     FPh_PID_Neutron  =  13, // 2112  
00056     FPh_PID_Proton   =  14, // 2212 
00057     FPh_PID_AProton  =  15, // -2212, 
00058     FPh_PID_ANeutron =  25, // -2112, 
00059     //
00060     FPh_PID_Lambda  = 18, //3122,  
00061     FPh_PID_ALambda = 26,
00062     //
00063     FPh_PID_Sigma_plu   =  19, // 3222,  
00064     FPh_PID_Sigma_zero  =  20, // 3212,  
00065     FPh_PID_Sigma_min   =  21, // 3112,  
00066     FPh_PID_ASigma_plu  =  29, // -3222, 
00067     FPh_PID_ASigma_zero =  28, // -3212, 
00068     FPh_PID_ASigma_min  =  27, // -3112, 
00069     //
00070     FPh_PID_Gamma    =  1, // 22
00071     FPh_PID_Deuteron = 45, //
00072     FPh_PID_Tritium  = 46, //
00073     FPh_PID_Alpha    = 47, //
00074     //
00075   }; 
00076   
00077   
00078   // methods declaration
00079   TString FidaVer_Name(E_FndFidaVersion ver = FIDAVER_603);
00080   Int_t   FidaVer_ID(E_FndFidaVersion ver   = FIDAVER_603);
00081 
00082   Double_t TrackRad2Mom(Double_t B=1);
00083   Double_t TrackMom2Rad(Double_t B=1);
00084   Double_t TrackRad_FromMom(Double_t mom,Double_t lam,Double_t B=1);
00085 
00086   Double_t GetBhaRate_Lumin_Factor();
00087 
00088   Double_t GetParticleMass(E_Fnd_PID pid); // Gev/c2
00089   //
00090   Double_t Sum(const Float_t &mod1,const Float_t &cdx1,const Float_t &cdy1,const Float_t &cdz1,
00091                const Float_t &mod2,const Float_t &cdx2,const Float_t &cdy2,const Float_t &cdz2,
00092                Double_t &cdx_res,Double_t &cdy_res,Double_t &cdz_res);
00093   //
00094   void ScalarProduct(const Float_t &mod1,const Float_t &cdx1,const Float_t &cdy1,const Float_t &cdz1,
00095                      const Float_t &mod2,const Float_t &cdx2,const Float_t &cdy2,const Float_t &cdz2,
00096                      Double_t &module,Double_t &angle_rad);
00097   //
00098   Double_t ParticleEnergy_2(E_Fnd_PID pid,const Float_t &mom); // E^2
00099   Double_t ParticleEnergy(E_Fnd_PID pid,const Float_t &mom);
00100   //
00101   Double_t KineticEnergy_2(const Float_t &mom1,const Float_t &cdx1,const Float_t &cdy1,const Float_t &cdz1,
00102                            const Float_t &mom2,const Float_t &cdx2,const Float_t &cdy2,const Float_t &cdz2);
00103   Double_t KineticEnergy(const Float_t &mom1,const Float_t &cdx1,const Float_t &cdy1,const Float_t &cdz1,
00104                          const Float_t &mom2,const Float_t &cdx2,const Float_t &cdy2,const Float_t &cdz2);
00105   //
00106   Double_t CenterMassEnergy(E_Fnd_PID pid1, const Float_t &mom1,const Float_t &cdx1,const Float_t &cdy1,const Float_t &cdz1,
00107                             E_Fnd_PID pid2, const Float_t &mom2,const Float_t &cdx2,const Float_t &cdy2,const Float_t &cdz2);
00108   
00109   
00110   // --- reference system change
00111   void RefSys_CosDir_To_Spheric(const Double_t &cx,const Double_t &cy,const Double_t &cz,Double_t &theta,Double_t &phi);
00112   void RefSys_Sphere_To_CosDir(const Double_t &theta,const Double_t &phi,Double_t &cx,Double_t &cy,Double_t &cz);
00113 
00114   TString HolleritToString(Int_t hollerit_in); // by Hyeongryul So (2003)
00115   
00117   // GENERAL METHODS USED FOR OFFLINE ANALYSIS //
00119   //
00120   Double_t Dedxfunc(Double_t Momentum, Double_t Mass, Double_t Charge, Double_t Zval, Double_t Aval, Double_t Ival);
00121   Double_t DedxfuncSi(Double_t Momentum, Double_t Mass, Double_t Charge);
00122   Double_t DedxfuncCh(Double_t Momentum, Double_t Mass, Double_t Charge);
00123   //
00124   Double_t Tenevsmom(Double_t Momentum, Double_t Mass);
00125   //
00126 };
00127 
00129 // Implementation will follow:
00131 
00132 //_______________________________
00133 inline Int_t FIN_PHYS::FidaVer_ID(E_FndFidaVersion ver){
00134 
00135   return (Int_t) ver;
00136 }
00137 
00138 //_______________________________
00139 inline  TString FIN_PHYS::FidaVer_Name(E_FndFidaVersion ver){
00140   // upgraded everytime a new version of fidarc/mc is released
00141   switch (ver){
00142   case FIDAVER_521: return "v_521";
00143   case FIDAVER_601: return "v_601";
00144   case FIDAVER_603: return "v_603";
00145   default: return "";
00146   }
00147 }
00148 
00149 //__________________________
00150 inline Double_t FIN_PHYS::TrackRad2Mom(Double_t B){
00151   // transv_mom = radius * <this factor>
00152   //
00153   // formula: p = 0.00300 * R * B
00154   //  [p] = GeV/c
00155   //  [R] = cm   (meters)
00156   //  [B] = T   (tesla)
00157 
00158   return (Double_t)(0.00300 * B);
00159 }
00160 
00161 //__________________________
00162 inline Double_t FIN_PHYS::TrackMom2Rad(Double_t B){
00163   // radius = transv_mom * <this factor>
00164 
00165   return (Double_t)( 1. / TrackRad2Mom(B) );
00166 }
00167 
00168 //__________________________
00169 inline Double_t FIN_PHYS::TrackRad_FromMom(Double_t mom,Double_t lam,Double_t B){
00170 
00171   Double_t mom_transv = mom * TMath::Cos(lam);
00172   Double_t rad = mom_transv * TrackMom2Rad(B);
00173   return rad;
00174 }
00175 
00176 //__________________________
00177 inline Double_t FIN_PHYS::GetBhaRate_Lumin_Factor(){
00178   // this value must be multiplied by the BHABHA rate
00179   //  in order to get the instantaneous luminosity
00180 
00181   return 1.4e+30;
00182 }
00183 
00184 //__________________________
00185 inline Double_t FIN_PHYS::GetParticleMass(E_Fnd_PID pid){
00186   // Get mass from PID code (Gev/c2)
00187   // returns "-1" in case pid is not supported
00188   
00189   switch(pid){
00190   case FPh_PID_Positron : return 0.00051099906;
00191   case FPh_PID_Electron : return 0.00051099906;
00192     //
00193   case FPh_PID_Muon_plu : return 0.105658389;
00194   case FPh_PID_Muon_min : return 0.105658389;
00195     //
00196   case FPh_PID_Pi_zero : return 0.1349764;
00197   case FPh_PID_Pi_plu  : return 0.1395700;
00198   case FPh_PID_Pi_min  : return 0.1395700;
00199     //
00200   case FPh_PID_Kaon_Long  : return 0.497672;
00201   case FPh_PID_Kaon_Short : return 0.497672;
00202   case FPh_PID_Kaon_plu   : return 0.493677;
00203   case FPh_PID_Kaon_min   : return 0.493677;
00204     //
00205   case FPh_PID_Neutron  : return 0.93956563;
00206   case FPh_PID_Proton   : return 0.93827231;
00207   case FPh_PID_AProton  : return 0.93827231;
00208   case FPh_PID_ANeutron : return 0.93956563;
00209     //
00210   case FPh_PID_Lambda   : return 1.115684;
00211   case FPh_PID_ALambda  : return 1.115684;
00212     //
00213   case FPh_PID_Sigma_plu    : return 1.18937;
00214   case FPh_PID_Sigma_zero   : return 1.19255;
00215   case FPh_PID_Sigma_min    : return 1.197436;
00216   case FPh_PID_ASigma_plu   : return 1.197436;
00217   case FPh_PID_ASigma_zero  : return 1.19255;
00218   case FPh_PID_ASigma_min   : return 1.18937;
00219     //
00220   case FPh_PID_Gamma     : return 0;
00221   case FPh_PID_Deuteron  : return 1.875613;
00222   case FPh_PID_Tritium   : return 2.80925;
00223   case FPh_PID_Alpha     : return 3.727417;
00224     //
00225   default:
00226     gROOT->Warning("FIN_PHYS::GetParticleMass","PID not suported (%d)",pid);
00227     return -1;
00228   }
00229 }
00230 
00231 //__________________________
00232 inline Double_t FIN_PHYS::Sum(const Float_t &mod1,const Float_t &cdx1,const Float_t &cdy1,const Float_t &cdz1,
00233                                         const Float_t &mod2,const Float_t &cdx2,const Float_t &cdy2,const Float_t &cdz2,
00234                                         Double_t &cdx_res,Double_t &cdy_res,Double_t &cdz_res){
00235   // vectorial sum of two vectors
00236   // mod[1-2] : vector modules
00237   // cd*[1-3] : director cosines
00238 
00239   Double_t module = TMath::Sqrt(
00240                                 mod1*mod1 + mod2*mod2 + 
00241                                 2 * (mod1*cdx1*mod2*cdx2+mod1*cdy1*mod2*cdy2+mod1*cdz1*mod2*cdz2)
00242                                 );
00243   
00244   cdx_res = (Double_t) cdx1 + cdx2;
00245   cdy_res = (Double_t) cdy1 + cdy2;
00246   cdz_res = (Double_t) cdz1 + cdz2;
00247 
00248   return module;
00249 
00250 }
00251 
00252 //__________________________
00253 inline void FIN_PHYS::ScalarProduct(const Float_t &mod1,const Float_t &cdx1,const Float_t &cdy1,const Float_t &cdz1,
00254                                         const Float_t &mod2,const Float_t &cdx2,const Float_t &cdy2,const Float_t &cdz2,
00255                                         Double_t &module,Double_t &angle_rad){
00256   // mod[1-2] : vector modules
00257   // cd*[1-3] : director cosines
00258   
00259   if(! mod1 || !mod2){
00260     module = 0;
00261     angle_rad = -999;
00262     return;
00263   }
00264 
00265   module = (Double_t) ( 
00266                        mod1 * cdx1 * mod2 * cdx2 + 
00267                        mod1 * cdy1 * mod2 * cdy2 + 
00268                        mod1 * cdz1 * mod2 * cdz2
00269                        );
00270   
00271   Double_t cos_ang = module / ( (Double_t) (mod1*mod2) );
00272   if(module != 0){ // can not evaluate the angle between null vectors
00273     angle_rad = TMath::ACos(cos_ang);
00274   }
00275   else angle_rad = -999;
00276 
00277   //  cout << "module sign: " << module << endl;
00278   module = TMath::Abs(module);
00279   //  cout << "module abs: " << module << endl << endl;
00280 
00281   return;
00282 }
00283 
00284 //__________________________
00285 inline Double_t FIN_PHYS::KineticEnergy_2(const Float_t &mom1,const Float_t &cdx1,const Float_t &cdy1,const Float_t &cdz1,
00286                                            const Float_t &mom2,const Float_t &cdx2,const Float_t &cdy2,const Float_t &cdz2){
00287   // compute the (kinetic energy^2) (Gev^2/c^2) of the given system
00288   // (according to the given cosines angles)
00289   
00290   Double_t kin_en = ((mom1*cdx1 + mom2*cdx2) * (mom1*cdx1 + mom2*cdx2) + 
00291                      (mom1*cdy1 + mom2*cdy2) * (mom1*cdy1 + mom2*cdy2) + 
00292                      (mom1*cdz1 + mom2*cdz2) * (mom1*cdz1 + mom2*cdz2)
00293                      );
00294   return kin_en;
00295   
00296 }
00297 
00298 //__________________________
00299 inline Double_t FIN_PHYS::KineticEnergy(const Float_t &mom1,const Float_t &cdx1,const Float_t &cdy1,const Float_t &cdz1,
00300                                         const Float_t &mom2,const Float_t &cdx2,const Float_t &cdy2,const Float_t &cdz2){
00301   // compute the (kinetic energy) (Gev/c) of the given system
00302   // (according to the given cosines angles)
00303   
00304   return TMath::Sqrt( KineticEnergy_2(mom1,cdx1,cdy1,cdz1,mom2,cdx2,cdy2,cdz2) );
00305 }
00306 
00307 //__________________________
00308 inline Double_t FIN_PHYS::CenterMassEnergy(E_Fnd_PID pid1,
00309                                            const Float_t &mom1,const Float_t &cdx1,const Float_t &cdy1,const Float_t &cdz1,
00310                                            E_Fnd_PID pid2,
00311                                            const Float_t &mom2,const Float_t &cdx2,const Float_t &cdy2,const Float_t &cdz2){
00312   // compute the invariant mass (Gev/c2) of the [pid1,pid2] system
00313   // (according to the given momenta)
00314   
00315   Double_t ene1 = ParticleEnergy(pid1,mom1); // take care: E^2
00316   Double_t ene2 = ParticleEnergy(pid2,mom2); // take care: E^2
00317   
00318   if(ene1 == 0 || ene2 ==0) return 0;
00319 
00320   Double_t Imass = TMath::Sqrt(
00321                                (ene1+ene2)*(ene1+ene2) - 
00322                                KineticEnergy_2(mom1,cdx1,cdy1,cdz1,mom2,cdx2,cdy2,cdz2)
00323                                );
00324   
00325   return Imass;
00326   
00327 }
00328 
00329 //__________________________
00330 inline Double_t FIN_PHYS::ParticleEnergy_2(E_Fnd_PID pid,const Float_t &mom){
00331   // compute the energy^2 (GeV^2) of the [pid] particle
00332   // (according to the given momentum)
00333   
00334   Double_t mass = GetParticleMass(pid);
00335   
00336   Double_t energy_2 = (Double_t) ( (mass * mass) + (mom * mom) );
00337   return energy_2;
00338 }
00339 
00340 //__________________________
00341 inline Double_t FIN_PHYS::ParticleEnergy(E_Fnd_PID pid,const Float_t &mom){
00342   // compute the energy (GeV) of the [pid] particle
00343   // (according to the given momentum)
00344 
00345   return  TMath::Sqrt( ParticleEnergy_2(pid,mom) );
00346 }
00347 
00348 //__________________________
00349 inline TString FIN_PHYS::HolleritToString(Int_t hollerit_in){
00350   // by Hyeongryul So (year 2003)
00351   // modified to TString by D. Faso (November 2006)
00352   // needed while reading content of zebra (hollerit code is used)
00353 
00354 /*   result[0] = (Char_t) ((hollerit_in >>  0) & 0xFF); */
00355 /*   result[1] = (Char_t) ((hollerit_in >>  8) & 0xFF); */
00356 /*   result[2] = (Char_t) ((hollerit_in >> 16) & 0xFF); */
00357 /*   result[3] = (Char_t) ((hollerit_in >> 24) & 0xFF); */
00358 /*   result[4] = '\0'; */
00359 
00360   TString res = "";
00361   res += (Char_t) ((hollerit_in >>  0) & 0xFF);
00362   res += (Char_t) ((hollerit_in >>  8) & 0xFF);
00363   res += (Char_t) ((hollerit_in >> 16) & 0xFF);
00364   res += (Char_t) ((hollerit_in >> 24) & 0xFF);
00365   res.Resize(4);
00366 
00367 /*   TString res; */
00368 /*   res.Form("%s%s%s%s", */
00369 /*         (Char_t) ((hollerit_in >>  0) & 0xFF), */
00370 /*         (Char_t) ((hollerit_in >>  8) & 0xFF), */
00371 /*         (Char_t) ((hollerit_in >> 16) & 0xFF), */
00372 /*         (Char_t) ((hollerit_in >> 24) & 0xFF) */
00373 /*         ); */
00374 
00375   return res;
00376     
00377 }
00378 
00379 
00380 // --- reference system change
00381 //__________________________
00382 inline void FIN_PHYS::RefSys_CosDir_To_Spheric(const Double_t &cx,const Double_t &cy,const Double_t &cz,Double_t &theta,Double_t &phi){
00383   // all angles are expressed in rad
00384   // cx,cy,cz: director-cosines
00385   // theta: angle to the z-axis (spherical coordinates)  
00386   // phi: angle to the x-axis in the xy plane (spherical coordinates)  
00387   
00388   theta = (Double_t)TMath::ACos(cz);
00389 
00390   if(cx != 0){
00391     phi = (Double_t) TMath::ATan(cy/cx);
00392     if(cx < 0) phi = (Double_t)(TMath::Pi()) + phi;
00393   }
00394   else{
00395     Double_t signe = (cy > 0) ? +1 : -1;
00396     phi = signe * (Double_t)(TMath::Pi() / 2);
00397   }
00398   
00399 }
00400 
00401 //__________________________
00402 inline void FIN_PHYS::RefSys_Sphere_To_CosDir(const Double_t &theta,const Double_t &phi,Double_t &cx,Double_t &cy,Double_t &cz){
00403   // all angles are expressed in rad
00404   // cx,cy,cz: director-cosines
00405   // theta: angle to the z-axis (spherical coordinates)  
00406   // phi: angle to the x-axis in the xy plane (spherical coordinates)  
00407   
00408   cx = (Double_t) ( TMath::Sin(theta) * TMath::Cos(phi) );
00409   cy = (Double_t) ( TMath::Sin(theta) * TMath::Sin(phi) );
00410   cz = (Double_t) ( TMath::Cos(theta) );
00411 }
00412 
00414 // GENERAL METHODS USED FOR OFFLINE ANALYSIS //
00416 
00417 //__________________________
00418 inline Double_t FIN_PHYS::Dedxfunc(Double_t Momentum, Double_t Mass, Double_t Charge, Double_t Zval, Double_t Aval, Double_t Ival)
00419 {
00420   // Momentum in GeV/c, Mass in GeV/c^2, Charge in elementary charge 
00421   Momentum *= 1000.;
00422   Mass *= 1000. ;
00423   // Momentum in MeV/c, Mass in MeV/c^2, Charge in elementary charge 
00424   // Zval Atomic Number of Medium
00425   // Aval Atomic Mass of Medium 
00426   // Ival mean Excitation Energy [eV]
00427   Double_t Energy = TMath::Sqrt(TMath::Power(Momentum,2.) + TMath::Power(Mass,2.));
00428   Double_t Beta = Momentum / Energy;
00429   Double_t Beta2 = TMath::Power(Beta,2.);
00430   Double_t Gamma = Energy / Mass;
00431   Double_t Gamma2 = TMath::Power(Gamma,2.);
00432   Double_t Dcons = 0.30707;
00433   //
00434   Double_t melect = GetParticleMass(FPh_PID_Electron) * 1000.;
00435   // Double_t relect = 2.817940285;
00436   Double_t ZA = Zval/Aval;
00437   Double_t I2 = TMath::Power(Ival,2.);
00438   //
00439   Double_t Bethe = Dcons * ZA * TMath::Power(Charge,2.) / Beta2;
00440   Double_t TMax = (2*melect*Beta2*Gamma2);
00441   TMax /= ((1+2*Gamma*melect/Mass)+(TMath::Power((melect/Mass),2)));
00442   Double_t ArgLog = (2*melect*Beta2*Gamma2*TMax/I2);
00443   Bethe *= (0.5 * TMath::Log(ArgLog) - Beta2);
00444   return Bethe;
00445 }
00446 
00447 //__________________________
00448 inline Double_t FIN_PHYS::DedxfuncSi(Double_t Momentum, Double_t Mass, Double_t Charge)
00449 {
00450   // Silicon
00451   //  Double_t rho = 2.33;
00452   Double_t Zval = 14.;
00453   Double_t Aval = 28.0855;
00454   Double_t Ival = 173.0E-6;
00455   //
00456   return Dedxfunc(Momentum, Mass, Charge, Zval, Aval, Ival);
00457 }
00458 
00459 //__________________________
00460 inline Double_t FIN_PHYS::DedxfuncCh(Double_t Momentum, Double_t Mass, Double_t Charge)
00461 {
00462   // Silicon
00463   //  Double_t rho = 2.33;
00464   Double_t Zval = 11.6;
00465   Double_t Aval = 20.2;
00466   Double_t Ival = 278.9E-6;
00467   //
00468   return Dedxfunc(Momentum, Mass, Charge, Zval, Aval, Ival);
00469 }
00470 
00471 //__________________________
00472 inline Double_t FIN_PHYS::Tenevsmom(Double_t Momentum, Double_t Mass)
00473 {
00474   return TMath::Sqrt(TMath::Power(Momentum,2.)+TMath::Power(Mass,2.)) - Mass;
00475 }
00476 
00477 //
00478 #endif // FROOT_FIN_PHYS

Generated on Tue Oct 16 15:40:46 2007 by  doxygen 1.5.2