FlyoDoc_2011 Pisa 2011 by GmP --- 011

flyopunta/src/src_ana/anak6g.cpp

00001 /***************************************************************************
00002                           anak6g.cpp  -  description
00003                              -------------------
00004     begin                : Sat Jan 18 2003
00005     copyright            : (C) 2003 by Giuseppe Pierazzini
00006     email                : peppe@unipi.it
00007   ***************************************************************************
00008   *                                                                         *
00009   *   NA48  simulation program.                                             *
00010   *                                                                         *
00011   ***************************************************************************/
00012 #define EPSR     1.0E-200
00013 #include "flyoh.h"
00014 #include "anak6g.h"
00015 #include "gmatrix.h"
00016 
00017 
00023 AnaK6g::AnaK6g()
00024 {
00025   tipo=2;nfit=6;titol="K--> 3 pi0 -> 6 gam" ;nome="K6gam";
00026   Gout<<"\n Ridefinito e creato il fit di "<<titol;
00027   // gmatrix set size;
00028   Bm64.Set_Size ( 6,4 );Az41.Set_Size ( 4,1 );
00029   F41.Set_Size ( 4,1 ); R41.Set_Size ( 4,1 );
00030   De61.Set_Size ( 6,1 );Lmd41.Set_Size ( 4,1 );
00031   Zm11.Set_Size ( 1,1 );
00032   Var66.Set_Size ( 6,6 ); InV66.Set_Size ( 6,6 );
00033 
00034   BVB.Set_Size ( 4,4 );
00035   GB.Set_Size ( 4,4 );
00036   AGBA.Set_Size ( 1,1 );
00037   Gx.Set_Size ( 1,1 );
00038   CHQ.Set_Size ( 1,1 );
00039 
00040 }
00041 AnaK6g::~AnaK6g() {}
00042 
00043 void AnaK6g::Reset_parm()
00044 {
00045   AnaK4g::Reset_parm();
00046   permut_flag=iter_flag=permut_fit=iter_fit=-1;
00047 
00048   dchi2=2000.;
00049   chisq=101.;
00050   ss6[0]=ss6[1]=ss6[2]=0.0;
00051   ws6[0]=ws6[1]=ws6[2]=1.;
00052 }
00053 
00054 
00055 //===========  =====  N e u t r a l   3 pi0   F i t ===
00056 
00057 int AnaK6g::Fisica()
00058 {
00059   
00066   if ( Debugon==1 ) Write_titol();
00067 
00068   count_call++;
00069   Reset_parm();
00070   ngm = mishit=lkry->mhit;
00071   if ( WrtNt>1 ) Reset_Dummy_Data();  // se si scrivono tutti gli eventi
00072 
00073 // also 7 gammas for dalitz....
00074   if ( mishit<6 ) {getta_gg++;dead6=-1;return -1;}
00075 //if( mishit>6 ) {getta_gg++;dead6=-1;return -1;}   //too many gammas..
00076 
00077   double xi,yi,egx;
00078   bmax=0.;egamtot=0.;
00079   int ngood=-1;
00080   for ( int i=0;i<mishit;i++ )
00081   {
00082 
00083     xi=lkry->M_Hits[i].Xdev.x;
00084     yi=lkry->M_Hits[i].Xdev.y;
00085     egx=lkry->M_Hits[i].e_rivela;
00086 
00087 
00088     if ( egx<3.||egx>100. ) {nextra++; continue;}  // giudici 2007 energia test
00089 
00090     // goemetrical cut
00091 
00092     double braccio=sqrt ( xi*xi+yi*yi ); if ( braccio>bmax ) bmax=braccio;
00093     if ( braccio<15. )               continue;
00094 //    if ( braccio>116. )             continue;   // circolar 116.
00095 
00096     double absx=fabs ( xi ), absy=fabs ( yi );
00097     if ( absx >116. || absy >116. ) continue;
00098     if ( absx +absy > 164. )       continue; // rectangular  116.*sqrt(2)
00099     if ( absx >63.2 && absy >84.7 ) continue;
00100     if ( absx >52.2 && absy >94.7 ) continue;
00101     if ( pow ( ( absx-63.2 ),2 ) +pow ( ( absy-94.7 ),2 ) < 121. )  continue;  //octagonal
00102 
00103 // save the good gammas in _sav
00104     ngood++;
00105     eg_sav[ngood]  =egx;
00106     xg_sav[ngood]  =xi;
00107     yg_sav[ngood]  =yi;
00108     zg_sav[ngood]  =lkry->M_Hits[i].Xlab.z;
00109     idpr_sav[ngood]=lkry->M_Hits[i].idm;
00110     egamtot+=egx;
00111   }
00112 
00113 
00114   // cut on gammas  on the base of fit type..here 6 [5 in C++]
00115   if ( ngood<5 ) {getta_gg++;dead6=-3;return -3;}
00116   if ( egamtot< 60. ) {getta_en++; dead6=-4;return -4;}
00117 
00118 
00119   int Debug_fit=0;  // per test se ==1
00120   if ( Debug_fit==1 )
00121   {
00122     int ngboni=ngood+1;
00123     Gout<<setprecision ( 3 );
00124     Gout<<"\n Start   "<<evento_.Gen.Event<<" whit "<<ngboni
00125     <<" gam  e zv "<<setw ( 8 ) <<evento_.Gen.zv <<" etot "<<setw ( 8 ) <<egamtot
00126     <<" Lkrz "<<lkry->Get_Cface().z;
00127     for ( int i=0;i<ngboni;i++ )
00128       Gout<<"\nG xyze "<<setw ( 8 ) <<xg_sav[i]<<" "
00129       <<setw ( 8 ) <<yg_sav[i]<<" "
00130       <<setw ( 8 ) <<eg_sav[i]<<" Idm "<<idpr_sav[i];
00131     Gout<<endl;
00132   }
00133 
00134 //    FITTING   begin
00135   nd=0;
00136   chisq=15.;
00137 
00138 // se ci sono sette gamma si itera sulle possibili 6-ple (sette ipotesi)
00139   int ik =0, ipotesi=1, iok=0;
00140   if ( ngood==6 ) ipotesi=7;
00141   while ( ik< ipotesi )
00142   {
00143     if ( Get_Data_from_saved ( ik ) <0 ) { ik++;continue;} // select the 6-pla
00144 
00145 // first large cuts on neasured values....just to speed up the fitting...gmatrix
00146     if ( egamtot< 60.||egamtot>180. ) {ik++;continue;}
00147     if ( cog > 100.0 ) {ik++;continue;}
00148     ik++;
00149 
00150 // debug ======gmatrix
00151     if ( Debug_fit>=2 )
00152     {
00153       for ( int i=0;i<6;i++ )
00154         Gout<<"\nC xyze "<<setw ( 8 ) <<xgood[i]<<" "
00155         <<setw ( 8 ) <<ygood[i]<<" "
00156         <<setw ( 8 ) <<egood[i]<<" Idm "<<idpr[i];
00157       Gout<<endl;
00158     }
00159 // end debug =====
00160 
00161 //    procedure    F I T T A
00162 
00163 
00164     if ( Fitta() ==1 ) iok=1;
00165   }
00166   if ( iok==0 ) return -1; // non ci sono fit ok...
00167   // debug =====
00168 
00169   if ( Debug_fit==1 )
00170   {
00171     Gout<<setprecision ( 3 );
00172     Gout<<"\n Fit ev   "<<evento_.Gen.Event<<" ipot. "<<ik<<" itr "<<iter_fit
00173     <<" chq "<<setw ( 8 ) <<chisq<<" zeta "<<setw ( 8 ) <<zeta <<" et "<<setw ( 8 ) <<egamt_fit;
00174 
00175     for ( int i=0;i<6;i++ )
00176       Gout<<"\nF xyze "<<setw ( 8 ) <<xg_fit[i]<<" " <<setw ( 8 ) <<yg_fit[i]
00177       <<setw ( 8 ) <<eg_fit[i]<<"  Perm "<<permut_fit<<" Idm "<<idpr_fit[i];
00178     Gout<<endl;
00179 
00180   }
00181 
00182 //  ------------fit done ----
00183   if ( egamt_fit<70. ||egamt_fit>170. ) {getta_en++; dead6=-4;return -4;}
00184 
00185   if ( chisq>15. )  {getta_fit++;dead6=-6;return -6;} // wrong chiq in the fit!
00186   if ( dist_fit<0.0 ) {getta_gf++;dead6=-7;return -7;} // wrong vx dist_fit
00187 //  if (cog_fit>20.0) {getta_cog++; dead6=-5;return -5;} // wrong cog_fit
00188   if ( cog_fit>100.0 ) {getta_cog++; dead6=-5;return -5;} // wrong cog_fit  19.07.09
00189 //  time life cut from aks for Kl
00190 //  aks=607.2; // posizione della coincidenza
00191   double volo=zeta-607.2;
00192 
00193 //massa Ks=0.497648;
00194   cvita= ( ( volo*0.497648 ) /egamt_fit ) /2.6842;    //19.07.09
00195 //  if ( cvita<-2.|| cvita>10. ) {getta_tau++;dead6=-8;return -8;}   //no il 19.07.09
00196   if ( cvita> ( 0.8+0.06*egamt_fit ) ) {getta_tau++;dead6=-9;return -9;}
00197 
00198 // define cinematic variables
00199 
00200   for ( int i=0;i<6;i++ )
00201   {
00202     Versg.setvn ( xg_fit[i],yg_fit[i],dist_fit ); Pgam=Versg.NVerso() *eg_fit[i];
00203     Gq[i].setvn ( Pgam,0.0 );
00204   }
00205 
00206 
00207   Pio01=Gq[0]+Gq[1];mgg[0]=  Pio01.Invarq();
00208   Pio23=Gq[2]+Gq[3];mgg[1]=  Pio23.Invarq();
00209   Pio45=Gq[4]+Gq[5];mgg[2]=  Pio45.Invarq();
00210   
00211   if(mgg[0]>0.)mgg[0]=sqrt(mgg[0]); else mgg[0]=-sqrt(fabs(mgg[0]));
00212   if(mgg[1]>0.)mgg[1]=sqrt(mgg[1]); else mgg[1]=-sqrt(fabs(mgg[1]));
00213   if(mgg[2]>0.)mgg[2]=sqrt(mgg[2]); else mgg[2]=-sqrt(fabs(mgg[2]));
00214   
00215   qvet Pm12=Pio23+Pio45;
00216   qvet Pm02=Pio01+Pio45;
00217   qvet Pm01=Pio23+Pio01;
00218 
00219   ss6[0]= Pm12.Invarq();
00220   ss6[1]= Pm02.Invarq();
00221   ss6[2]= Pm01.Invarq();
00222   
00223   vss6[0]= fabs(ss6[1]-ss6[2])*0.577350269;//1./sqrt(3.)
00224   vss6[1]= fabs(ss6[2]-ss6[0])*0.577350269;
00225   vss6[2]= fabs(ss6[0]-ss6[1])*0.577350269;
00226 
00227   int Irand=evento_.Gen.Irand_ss;
00228 
00229   if ( Irand==0 )
00230   {
00231     ss6_sort=ss6[0];  
00232     vss6_sort=vss6[0];
00233   }
00234   else if ( Irand==1 )
00235   {
00236     ss6_sort=ss6[1];  
00237     vss6_sort=vss6[1];
00238   }
00239   else if ( Irand==2 )
00240   {
00241     ss6_sort=ss6[2];  
00242     vss6_sort=vss6[2]; 
00243   }
00244   
00245   
00246   
00247 
00248 //   Pio01.print("p01");  Gout<<setprecision(6)<<" "<<Pio01.m<<"  pi0m "<<pi0mass<<" " <<4.*pi0massq;
00249 //   Pio23.print("p23");  Gout<<setprecision(6)<<" "<<Pio23.m<<" ss6[0] "<<ss6[0]<<" " <<evento_.Gen.ss0;
00250 //   Pio45.print("p45");  Gout<<setprecision(6)<<" "<<Pio45.m<<" dif "<<ss6[0]-evento_.Gen.ss0;
00251 
00252 
00253 // calcolo il peso per ogni ss
00254   double wpeso;
00255   wpeso=Fspace ( 0.49767,Pm12.m, 0.13497 )  *Fspace ( Pm12.m, 0.13497,0.13497 );
00256   if ( wpeso>0.0 ) ws6[0]=1./wpeso;
00257   wpeso=Fspace ( 0.49767,Pm02.m, 0.13497 ) *Fspace ( Pm02.m, 0.13497,0.13497 );
00258   if ( wpeso>0.0 ) ws6[1]=1./wpeso;
00259   wpeso=Fspace ( 0.49767,Pm01.m, 0.13497 ) *Fspace ( Pm01.m, 0.13497,0.13497 );
00260   if ( wpeso>0.0 ) ws6[2]=1./wpeso;
00261   //-------------------------
00262   count_wnt++; dead6=0;
00263   return 1;
00264 }
00265 
00266 
00267 void AnaK6g::Reset_Dummy_Data()
00268 {
00269   chisq=100.;
00270   zeta=SelRea->avo->X.z;
00271   cvita= ( ( zeta-607.5 ) *msAvo/evento_.Gen.pk ) /2.6842;
00272   egamt_fit=egamtot;
00273   for ( int i=0;i<mishit;i++ ) eg_fit[i]=lkry->M_Hits[i].e_rivela;
00274   for ( int i=mishit;i<6;i++ ) eg_fit[i]=-1.0;
00275   dead6=0;
00276 }
00277 
00278 
00279 
00280 
00281 
00282 
00283 //----------------------------------------------------------
00284 int AnaK6g::Fitta()
00285 {
00286 
00287   double Fsum,chiq=0.0;
00288   double Fsum_cut=0.00001;
00289 //  double Fsum_cut=0.00001;
00290   //-----------------  l o o f i t -------
00291   int iter,ipr;
00292   int iok=0;
00293   last_chiq=100.;
00294   int debugfit=0;
00295   if ( evento_.Gen.Event>1&&evento_.Gen.Event<20 ) debugfit=1;
00296 
00297   for ( ipr=0;ipr<15;ipr++ )
00298   {
00299     Permutazione ( ipr );// get the right permutated parameters (0-1,2-3,4-5)
00300 
00301     InV66=!Var66;
00302     De61.Reset();
00303 
00304     if ( ( Fsum=Calcolo_Vincoli() ) >1.0 ) {chiq=999.;continue;}
00305 
00306     for ( iter=0;iter<20;iter++ )
00307     {
00308       //   Gout<<"\n\n Start  Evento :  "<< evento_.Gen.Event<< "  ipr,iter: "<< ipr<<" "<<iter;
00309       //  calcolo i vincoli e le derivate (vincoli troppo alti return 10.)
00310 
00311 //      if ( ( Fsum=Calcolo_Vincoli() ) >1.0 ) {chiq=999.;break;}
00312 
00313 
00314       // algebra di fit.. 9 variabili ed un parametro;
00315       BVB = ( ~Bm64 ) * ( Var66*Bm64 );
00316 
00317       GB= !BVB;
00318       if ( GB.okflag<0 )
00319       {
00320         Gout<<"\n BVB Okflag error  Ev "<<evento_.Gen.Event;
00321         break;
00322       }
00323 
00324       AGBA = ~Az41*GB*Az41;
00325 
00326       //if(evento_.Gen.Event==1392&& ipr==0){AGBA.Det();AGBA.Print("AGBA");}
00327 
00328       Gx=!AGBA;
00329       if ( Gx.okflag<0 )
00330       {
00331         Gout<<"\n AGBA Okflag error  Ev "<<evento_.Gen.Event;
00332         break;
00333       }
00334 
00335       Zm11= -Gx*~Az41*GB*R41;
00336       Lmd41=GB* ( Az41*Zm11+R41 );
00337       gmatrix daux=Bm64*Lmd41;
00338       De61=-Var66*daux;
00339 
00340       // updating
00341       dist_vertex+= Zm11 ( 0,0 );
00342       distq=dist_vertex*dist_vertex;
00343       for ( int i =0;i<6;i++ ) ec[i]=De61 ( i,0 ) +em[i];
00344 
00345       //  test of iteration end.
00346       CHQ= ~De61*InV66*De61;
00347       chiq=CHQ ( 0,0 );
00348       if ( iter>0&&chiq>100. ) { break; } // skip very  bad permutation fit
00349       if ( ( Fsum=Calcolo_Vincoli() ) >1.0 ) {chiq=999.;break;}// skip very  bad permutation fit
00350 
00351 
00352 // test to save good data...
00353       if ( Fsum<Fsum_cut &&iter>1 )
00354       {
00355         dchi2=abs(last_chiq-chiq);
00356 
00357         if ( dchi2 <20. )
00358         {
00359  /*         Gout<<setprecision ( 5 );
00360           Gout<<"\n Fitta: "<<evento_.Gen.Event<<std::scientific
00361           <<" chiq " <<setw ( 12 ) <<chiq <<" diffq "<<setw ( 12 ) <<dchi2<<" " <<setw ( 12 )
00362           <<Fsum<<" ipr " <<ipr<< " itr " << iter;
00363 */
00364 
00365           return -1;  // Si accettano gli eventi in cui l'accoppiamento non è degenere!!!!
00366         }
00367         if ( chiq>chisq ) break;  // if worse than the last one
00368 
00369 
00370 // save the best data
00371 
00372 
00373         chisq=chiq;
00374         permut_flag = ipr;
00375         iter_flag=iter;
00376         Save_good_fit();
00377         last_chiq=chisq;
00378         iok=1;
00379 
00380 
00381 
00382 // debug....====
00383 
00384         if ( debugfit==1 )
00385         {
00386 
00387           double Smas=0.0;
00388           for ( int i=0;i<5;i++ )
00389           {
00390             for ( int j=i+1;j<6;j++ )
00391               { Smas+= ec[i]*ec[j]*dq[i][j];}
00392           }
00393           Gout<<setprecision ( 5 );
00394           Gout<<"\n Fitta out  Ev "<<evento_.Gen.Event<< " chq "<<chisq <<" Fsum: "<< Fsum
00395           <<" ipr "<<ipr<< " itr "<<iter
00396           <<"  mas_k  "<< sqrt ( Smas/distq ) <<endl;
00397 //          for ( int i=0;i<6;i++ ) Gout<<" [ "<<em[i]<<" "<<ec[i]<<" ]";Gout<<endl;
00398         }
00399         break;
00400 
00401       }
00402     }  //iter end....
00403 
00404 
00405 
00406   } // end permutazioni
00407   return iok;
00408 }
00409 
00410 
00411 double AnaK6g::Calcolo_Vincoli ()
00412 {
00413   //atenzione si usano le matrici.....
00414   // dei vincoli e delle sue derivate.
00415   static double  deltz= 0.01,deltg=0.0001;
00416   double Fsum=0.0;
00417   int i4,ifu;
00418   for ( i4=0;i4<4;i4++ )
00419   {
00420     F41 ( i4,0 ) = F_Vinc ( i4,ec,dist_vertex,-1 ,0.0 );
00421     Fsum+=abs ( F41 ( i4,0 ) );
00422   }
00423   if ( Fsum>1. ) return 10.;  // vincoli non soddisfatti
00424   // derivate
00425   for ( i4=0;i4<4;i4++ )
00426   {
00427     Az41 ( i4,0 ) =0.5* ( F_Vinc ( i4,ec,dist_vertex,10,deltz )-F_Vinc ( i4,ec,dist_vertex,10,-deltz ) ) /deltz;
00428     for ( int i=0; i<6;i++ )
00429     {
00430       ifu=i;
00431       Bm64 ( i,i4 ) =0.5* ( F_Vinc ( i4,ec,dist_vertex,ifu,deltg )-F_Vinc ( i4,ec,dist_vertex,ifu,-deltg ) ) /deltg;
00432     }
00433   }
00434   R41= ( F41- ( ~Bm64 ) *De61 );// residui ...algebra matriciale....in gmatrix.h
00435   return Fsum;
00436 }
00437 //------------------------------------
00438 double AnaK6g::F_Vinc ( int i4,double *ec ,double dist,int id,double delta )
00439 {
00440   // procedura per calcolare i valori dei vincoli
00441   double zd,ecd[6];
00442   double  zdq,fsum=0.0;
00443 
00444   // ----------------------------
00445   // ridefisce i parametri per il cacolo anche delle derivate!
00446   for ( int i=0;i<6;i++ )  // energia e zeta
00447   {
00448     ecd[i]=ec[i];
00449     if ( id==i ) ecd[i]+=delta;
00450   }
00451   //la zeta del vertice
00452   zd=dist;
00453   if ( id==10 ) zd+=delta;
00454   zdq=zd*zd;
00455   //--------------------------------
00456   // calcolo dei vincoli normalizzati alla massa.
00457   switch ( i4 )
00458   {
00459     case 0:
00460       fsum= ecd[0]*ecd[1]*dq[0][1];
00461       return ( fsum/zdq-pi0massq );
00462 //      return abs ( fsum/zdq-pi0massq );  ma perchè!!!!!!!!!!!!!!!!!!!buttare.....
00463 
00464       break;
00465     case 1:
00466       fsum= ecd[2]*ecd[3]*dq[2][3];
00467       return ( fsum/zdq-pi0massq );
00468 //      return abs ( fsum/zdq-pi0massq );
00469 
00470       break;
00471     case 2:
00472       fsum= ecd[4]*ecd[5]*dq[4][5];
00473       return ( fsum/zdq-pi0massq );
00474 //      return abs ( fsum/zdq-pi0massq );
00475       break;
00476     case 3:
00477       fsum=0.0;
00478       for ( int i=0;i<5;i++ )
00479       {
00480         for ( int j=i+1;j<6;j++ )
00481           { fsum+= ecd[i]*ecd[j]*dq[i][j];}
00482       }
00483 //    if(evento_.Gen.Event==1392)
00484 //      Gout<<"\n F_Vinc "<<setprecision(5)<<" s "<<fsum <<" z "<<zd<<" mkq "<< msqAvo <<"
00485 //   "<<fsum/(zdq)<<" " <<id;
00486       return ( fsum/zdq -msqAvo );
00487 //      return abs ( fsum/zdq -msqAvo );
00488       break;
00489     default:
00490       printf ( "errore in F_Vinc\n" ); exit ( -1 );
00491       break;
00492   }
00493   return 0.0;
00494 }
00495 //*****
00496 void AnaK6g::Permutazione ( int ipr )
00497 {
00498   // perumtazion ipr (0-14);
00499   // ricava le informazioni di base.
00500   //  Ditanze tra i gamma e previosione di dist_vertex
00501   int jc;
00502   int * Perm=Get_Permuta ( ipr );
00503   double corr_errorq= 1.21;
00504 //    se= sqrt(0.01 + (0.001024+2.5e-5*ep)*ep);       // 1998
00505 //    se= sqrt ( 0.0081 + ( 0.001024+1.764e-5*ep ) *ep );      //1999
00506 
00507   for ( int i =0;i<6;i++ )
00508   {
00509     jc=Perm[i];
00510     em[i]=ec[i]=egood[jc];
00511     Var66 ( i,i ) = ( 0.0081 + ( 0.001024+1.764e-5*egood[jc] ) *egood[jc] ) *corr_errorq;
00512 
00513     //  Var66 ( i,i ) = ( 0.01 + ( 0.001024+2.5e-5*egood[jc] ) *egood[jc] );
00514 
00515 
00516     xg[i]=xgood[jc];
00517     yg[i]=ygood[jc];
00518 
00519   }
00520 
00521   //Distanze tra gli hits dei gamma.
00522   double dx,dy;
00523   for ( int i =0;i<6;i++ )
00524   {
00525     for ( int j =i+1;j<6;j++ )
00526     {
00527       dx=xg[i]-xg[j];
00528       dy=yg[i]-yg[j];
00529       dq[i][j]=dq[j][i]=dx*dx+dy*dy;
00530     }
00531   }
00532 
00533   // inizializzo la distanza del vertice dal cal.
00534   double fsum=0.0;
00535   for ( int i=0;i<6-1;i++ )
00536   {
00537     for ( int j=i+1;j<6;j++ )
00538       { fsum+= ec[i]*ec[j]*dq[i][j];}
00539   }
00540   dist_vertex=sqrt ( fsum/msqAvo );
00541 
00542 
00543 }
00544 //---------------------------------
00545 int * AnaK6g::Get_Permuta ( int ipr )
00546 {
00547   // permutation indexes...
00548   static int  iperm[15][6] =
00549   {
00550     {0,1,2,3,4,5},{0,1,2,4,3,5},{0,1,2,5,4,3},
00551     {0,2,1,3,4,5},{0,2,1,4,3,5},{0,2,1,5,4,3},
00552     {0,3,2,1,4,5},{0,3,2,4,1,5},{0,3,2,5,4,1},
00553     {0,4,2,3,1,5},{0,4,2,1,3,5},{0,4,2,5,1,3},
00554     {0,5,2,3,4,1},{0,5,2,4,3,1},{0,5,2,1,4,3}
00555   };
00556 
00557   return iperm[ipr];
00558 }
00559 //-------------------------
00560 int AnaK6g::Get_Data_from_saved ( int k )
00561 {
00562 // sceglie i gamma in una lista ordinata di 7 gamma
00563 // parte dal gamma  k e copia i primi sei i successione tornando a zero dopo il settimo..
00564   int kora=k;
00565   double xi,yi,xcog=0.0,ycog=0.0,egx;
00566   egamtot=0.;
00567   for ( int i=0;i<6;i++ )
00568   {
00569     kora=kora%7;
00570     egood[i]=egx=eg_sav[kora];
00571     xgood[i]=xi=xg_sav[kora];
00572     ygood[i]=yi=yg_sav[kora];
00573     idpr[i] =idpr_sav[kora];
00574     xcog+=egx*xi;
00575     ycog+=egx*yi;
00576     egamtot+=egx;
00577     kora++;
00578 
00579   }
00580 // check the separation between gammas (importantissimo non dimenticare....)
00581   double x,y;
00582   int ii;
00583   for ( int i=0;i<6;i++ )
00584   {
00585     x=xgood[i];
00586     y=ygood[i];
00587     ii=i+1;
00588     for ( int j=ii;j<6;j++ )
00589     {
00590       if ( ( pow ( ( x-xgood[j] ),2 ) +pow ( ( y-ygood[j] ),2 ) ) <100. ) return -1;
00591     }
00592   }
00593   xcog/=egamtot; ycog/=egamtot;
00594   cog=sqrt ( xcog*xcog+ycog*ycog );
00595 
00596   return 1;
00597 }
00598 
00599 // ----------------------
00600 void  AnaK6g::Save_good_fit()
00601 {
00602   double xi,yi,xcog=0.0,ycog=0.0,egx;
00603 //  dist_fit=dist_vertex+15.;
00604   dist_fit=dist_vertex;
00605   zeta=lkry->Get_Cface().z-dist_fit;
00606   permut_fit=permut_flag;
00607   iter_fit=iter_flag;
00608   egamt_fit=0.0;
00609   for ( int i=0;i<6;i++ )
00610   {
00611     egamt_fit+=eg_fit[i]=egx=ec[i];
00612     xg_fit[i]=xi=xg[i];
00613     yg_fit[i]=yi=yg[i];
00614     idpr_fit[i]=idpr[i];
00615     xcog+=egx*xi;
00616     ycog+=egx*yi;
00617   }
00618   xcog/=egamt_fit; ycog/=egamt_fit;
00619   cog_fit=sqrt ( xcog*xcog+ycog*ycog );
00620 }
 All Classes Namespaces Files Functions Variables