FlyoDoc_2011 Pisa 2011 by GmP --- 011

flyopunta/src/src_main/evento.cpp

00001 /***************************************************************************
00002                           evento.cpp  -  description
00003                              -------------------
00004     begin                : Sun May 27 2001
00005     copyright            : (C) 2001 by Giuseppe Pierazzini
00006     email                : peppe@unipi.it
00007   ***************************************************************************
00008   *                                                                         *
00009   *   NA48  simulation program.                                             *
00010   *                                                                         *
00011   ***************************************************************************/
00012 #define EVENTO
00013 #include "flyoh.h"
00014 #include "flyoana.h"
00015 
00016 //using namespace std;
00021 Evento::Evento()
00022 {
00023 
00024 
00025   Gen.Run =1000;  //default
00026   Mxev=120;
00027   Gen.Event = Debg_first = Evenlast=0;
00028   Gen.Ifus=0;
00029   Debg_last = 3;
00030   Gen.type=Gen.lastype=0;
00031   SizeCircularBuffer=100;
00032 
00033   MemEvPos=0;
00034 
00035 
00036 }
00037 
00038 
00039 void Evento::Put_Header_into_Buffer()
00040 {
00041 // se รจ attivata la pipeline memorizzo i dati di generazione dell'evento
00042   // nel buffer circolare di evento.
00043   HeaderEv[MemEvPos]=Gen;
00044 //  Gout<<"\n --> Ev "<<Gen.Event<<" in memPos "<<MemEvPos<<" at time "<<Gen.tempo;
00045   MemEvPos++;
00046   MemEvPos= MemEvPos%SizeCircularBuffer;  // circular buffer
00047 
00048 
00049 
00050 }
00051 
00052 //------------------------------
00053 
00054 void Evento::Define_Standard_Header()
00055 {
00056   // store the header info in Gen
00057   Particella *pr,*pdw,*prg;
00058   pr=SelRea->avo;
00059 
00060   //   type=100*pr->Get_Idm()+SelRea->Get_Id(); and
00061   //   lastype   defined in Reazione->AddGen()
00062 
00063   Gen.ift=pr->Get_Ifato();
00064   Gen.Pipev=0;
00065   Gen.ttrigdif=Gen.tempo-Time_trigger_last;
00066   Time_trigger_last=Gen.tempo;
00067   Gen.pxk=pr->Get_Gpx();
00068   Gen.pyk=pr->Get_Gpy();
00069   Gen.pzk=pr->Get_Gpz();
00070   Gen.pk =pr->Get_Gpn();
00071   SelRea->Xtarg.putv( Gen.xt,Gen.yt,Gen.zt );
00072   pr->X.putv( Gen.xv,Gen.yv,Gen.zv );
00073   Gen.pkf =pr->P.norma;
00074   Gen.pxkf=pr->P[0];
00075   Gen.pykf=pr->P[1];
00076   Gen.pzkf=pr->P[2];
00077 
00078 //  clear of next data....
00079 
00080   float *zero=&Gen.x1f;
00081   for ( int i=0;i<20;i++ )
00082   {
00083     zero[i]=0.0;
00084   }
00085 
00086   pdw=pr->dw;
00087   if ( pdw!=0 )
00088   {
00089     pdw->X.putv( Gen.x1f,Gen.y1f,Gen.z1f );
00090     pdw->Get_Gp().putv( Gen.px1g,Gen.py1g,Gen.pz1g);
00091     Gen.mas1=pdw->Get_Massa();
00092     pdw->P.putv( Gen.px1f,Gen.py1f,Gen.pz1f);
00093   }
00094   prg=pr->rg;
00095   if ( prg!=0 )
00096   {
00097     prg->X.putv( Gen.x2f,Gen.y2f,Gen.z2f );
00098     prg->Get_Gp().putv( Gen.px2g,Gen.py2g,Gen.pz2g);
00099     Gen.mas2=prg->Get_Massa();
00100     prg->P.putv( Gen.px2f,Gen.py2f,Gen.pz2f);
00101   }
00102 
00103 // Vedi PartFase....
00104   if ( SelRea->ss_done==0 )
00105   {
00106     Gen.gss0=Gen.gss1=Gen.gss2=0.0;
00107     Gen.gvss0=Gen.gvss1=Gen.gvss2=0.0;
00108     Gen.gss_sort=Gen.gvss_sort=0.0;
00109   }
00110 
00111 
00112   Gen.rea_sel=SelRea;
00113 
00114 }
00115 
00116 
00117 
00118 
00119 
00120 
00121 //=================================================================
00122 int  Evento::Get_Header_from_Buffer()
00123 {
00124   Ntrigg=Ntrigg%SizeCircularBuffer;  // circular buffer
00125   double trigger_time = HeaderEv[Ntrigg].tempo; //if -1 event allready used to reject
00126   double tnow=TBurst->Get_Tempo();
00127 
00128   if ( trigger_time< 0. ) return -1;
00129 
00130 
00131   if ( ( tnow-trigger_time ) <Tpipe ) return -1; // Tpipe not yet elapsed from the last event...get out
00132 
00133   // ok copio l'header in Gen.
00134   Gen=HeaderEv[Ntrigg];
00135   SelRea=Gen.rea_sel;     // questo non dovrebbe servire ... da qui in poi potrebbe essere scorretto...
00136   /*
00137      Gout<<"\n Get from buffer Ev "<<Gen.Event<<" Ntrigb "<<Ntrigg<<" trig_time "
00138          <<trigger_time<< " tnow "<<tnow
00139          <<" type "<< Gen.type;
00140   */
00141 
00142 
00143   HeaderEv[Ntrigg].tempo=-1.;   // trigger  killed
00144   Ntrigg++;
00145 
00146 
00147 
00148   // get the  dev  hits
00149   Device *dev=Apparato;
00150   while ( dev!=0 )
00151   {
00152     if ( dev->escludi!=1 )
00153       dev->GetWindowHits ( trigger_time );
00154     dev= dev->next;
00155 
00156   }
00157   if ( evento_.Gen.Pipev>0 ) SelRea->Pipev++;
00158   return 1;
00159 
00160 }
 All Classes Namespaces Files Functions Variables