FlyoDoc_2011 Pisa 2011 by GmP --- 011
Defines | Functions | Variables

flyopunta/src/src_main/mainuti.cpp File Reference

#include "flyoh.h"

Go to the source code of this file.

Functions

void flyoinit ()
int flyoevento ()
void flyosimuladev ()
void flyoend ()

Variables

ParticellaPr_avo
Particellapr
Particellapb
Particellapc

Detailed Description

Contiene:


Author:
Giuseppe Pierazzini

Definition in file mainuti.cpp.


Function Documentation

void flyoend ( )

Termina la simulazione, Scrive il sommario sulla file di linsting di uscita.
Da i tempi di elaborazione globali.

Definition at line 413 of file mainuti.cpp.

{
    Gout<<"\n------------ Device hit summary   ----------";
    Apparato->Dev_summary();
    Gout<<"\n------------         E n d        ----------";
    Gout<<"\n---                                     ----\n";
    if ( Le_Tracce!=0 )
        Gout<<"\n Charged tracks info.. "<<Tracc[0]->tottrk<<" "<<Tracc[1]->tottrk<<" "<<Tracc[2]->tottrk<<endl;
    Reaction->Fine_run ();

    clockend = time ( &tck );
    double dft=clockend-clockstart;
    double evsec =Eventi_Fatti/dft;

    Gout<<"\n T start "<<clockstart<<"  e stop "<<clockend<<"  e diff  "<<dft<<" Sec."<<endl;
    Gout<<"\n Epsi Event/sec = "<<setw ( 10 ) <<evsec<<endl;

    Gout<<"\n Epsi main loop start at "<<setw ( 25 ) <<ctime ( &clockstart ) <<endl;
    Gout<<"\n Epsi main loop end   at "<<setw ( 25 ) <<ctime ( &clockend ) <<endl;


}
int flyoevento ( )

Genera le reazioni secondo le richieste dell'utente e traccia tutte le particelle nell'apparato.

Definition at line 163 of file mainuti.cpp.

{



    //   int colpo=0, visto = 0,debaggati=0;
    colpo=0;

//  se Correla=2 inizializzazione di random secondo l'evento e run
    if ( Correla==2 ) Set_PranEv();

    Debugon=1;
    if ( Eventi_Fatti < evento_.Debg_first ) Debugon=0;
    if ( Eventi_Fatti > evento_.Debg_last ) Debugon=0;

    if ( Eventi_Fatti % Mostra == 0 )
    {
        clockend = time ( &tck );
        double Elapsed=clockend-clockstart;
        double FromLast=clockend-clocklast;
        double pevsec=-1.,evsec =-1.;




        if ( Elapsed>0.0 ) evsec=Eventi_Fatti/Elapsed;
        if ( FromLast>0.0 ) pevsec= ( Eventi_Fatti-evento_.Evenlast ) /FromLast;

        std::ostringstream strs;
        strs << pevsec;
        std::string str = strs.str();
        if (pevsec<0.) str="inf";

        cout<<"\n Run "<<evento_.Gen.Run
            <<"  Ev. "<<setw ( 8 ) <<Eventi_Fatti
            <<"  Ev/s "<<setw ( 8 ) << str.c_str()
            <<"  Ev/s medio "<<setw ( 8 ) <<evsec
            <<"  elapsed  "<<Elapsed
            <<" At "<<ctime ( &clockend );

        cout<<endl;

        Gout<<setprecision ( 1 );
        Gout<<"\n Run "<<evento_.Gen.Run
        <<"  Ev. "<<setw ( 8 ) <<Eventi_Fatti
        <<"  Ev/s "<<setw ( 8 ) << str.c_str()
        <<"  Ev/s medio "<<setw ( 8 ) <<evsec
        <<"  elapsed  "<<Elapsed
        <<" At "<<ctime ( &clockend );

        clocklast=clockend;
        evento_.Evenlast=Eventi_Fatti;

    }
// reset the old reaction....

//   if(SelRea!=0) SelRea->Reset_Rea();

    // get the reaction pointer according to the rate...
    if ( ( SelRea = Reaction->Select_reation () ) == 0 )
    {
        Gout<<"\n Reaction not found... exit"<<endl;
        exit ( 0 );
    }
    SelRea->AddGen();

    if ( Debugon==1 )
    {
        debaggati++;
        Gout<<"\n\nRun "
        <<setprecision ( 0 ) <<fixed
        <<setw ( 6 ) <<evento_.Gen.Run<<"  E v e n t o "
        <<setw ( 6 ) <<Eventi_Fatti<<"  Dbg="
        <<setw ( 6 ) <<debaggati<<" "
        <<setw ( 25 ) <<SelRea->Get_Titolo() <<endl;
    }
    // =================== reset param...=====================================
    Pr_avo = SelRea->avo;
//-------------------

// get the beam  (for the moment Get_Beam returns allways 1! but just in the case...
    if ( SelRea->Get_Beam () ==0 )  return ( -2 );

//--------------------------------------------

    visto=0;

//   trasport the first particle della reazione...
    colpo = Pr_avo->Trasport();
//   Pr_avo->Stampa_questa_particella();
    visto+= colpo;
// if the beam do not decay or has not gas intaractions...get out

    if ( Pr_avo->dw!=0 || Pr_avo->cls!=0 );
    else if ( SelRea->rea_type==-1 )
    {
        visto=1;
        return ( 1 );
    }

    if ( colpo<0 )
    {
        return ( colpo );
    }

//================================ l o o p  for the other particles =========//
//  decay loop ....dei decadimenti .
// main loop: iterative procedura to follow the reaction tree...





    if ( Pr_avo->dw!=0 || Pr_avo->cls!=0 ) //non un urto: decay oppure gas
    { // la particella padre decade comunque....
        // se è un proiettile che ha interagito non decade vedi PartBullet::Get_Bersaglio()
        Pr_avo->Set_Pbar();
        Pr_avo->Main_Loop();  //vedi qui sotto il sorgente
//        cout<<"\n DGEv dopo main  "<<Eventi_Fatti<<" colpo "<<colpo<<" visto "<<visto;
    }


    if ( Pr_avo->Get_Type() ==Bullet )
    { // la particella padre è il proiettile
        // il bersaglio è alla sua destra.....
        // ccms è il sistema virtuale (proiettile -bersaglio)
        // i cui parametri sono definiti in PartBullet::Get_Bersaglio()
//     Gout<<"\n "<<Eventi_Fatti<<" è una Bullet....";
        Particella * ccms=Pr_avo->rg->dw;
        ccms->Set_Pbar();
        ccms->Main_Loop();
    }



// qui solo per debug
//  if(Eventi_Fatti==151) SelRea->Simple_List();

    if ( Debugon==1 )
    {
        Pr_avo->Stampa_particle ( SelRea );
        Gout<<endl;
    }


//============================  main l o o p   end===================//

    //------------update special counters ---
    SelRea->Totpair+=   SelRea->Pair_done;
    SelRea->Totbrem+=  SelRea->Brem_done;
    SelRea->Totdltz+=   SelRea->Dalitz_done;
    evento_.Gen.Ipair=SelRea->Pair_done;
    evento_.Gen.Ibrem=SelRea->Brem_done;
    evento_.Gen.Idlz =SelRea->Dalitz_done;

    if ( Debugon==1 ) SelRea->avo->Debug_out ();

//  cout<<"\n Run-spia "<<evento_.Gen.Run  <<"  Ev. "<<setw ( 8 ) <<Eventi_Fatti<<endl;

    return ( visto );
}
void flyoinit ( )

Inizializza tutta la procedura di simulazione. Definisce le file di lettura e scrittura (vedi File_Manager()) ed i parametri di controllo della simulazione (vedi carte.cpp e Leggi_input_File(cardin)).


Per il momento è specializzato per gli esperimenti NA48 e NA62, ma può facilmente essere generalizzato ad altre geometrie.

Definition at line 31 of file mainuti.cpp.

{

    //-------------------------------------------------------------
    cout<<"\n <><><><><><><><><><><><><><><><><><><><><><><><><>"<<endl;
    cout<<"\n  Flyo starts  running "<< ctime ( &clockstart );
    clockstart=clocklast = time ( &tck );
    Gout<<"\n  Flyo starts  running "<< ctime ( &clockstart );
    Gout<<"\n <><><><><><><><><><><><><><><><><><><><><><><><><>"<<endl;
    //------------------------------------------------------------------



    // Inizializzazione....
    TBurst=new Tempo();

// crea il data base delle particelle .
//Se manacano particelle aggiungere in:   Crea_part_db();
    Crea_part_db();
// crea il data base dei materiali
//Se manacano materiali aggiungere in:   Crea_materiali_db();
    Crea_materiali_db();

// si legge le file .epc e .app
    File_Manager();
    Sommario_Input_Data();


// first call... initialization

    if ( Reaction==0 )
    {
        Gout<<"\n Reactions not defined.. exit!!";
        exit ( 0 );
    }
    Reaction->MaxSpettro();
    Reaction->Norma_Rate(); // rate normalization
    Reaction->Simple_List();
    Gout<<"\n\n"<<endl ;

    // get dev pointers. Attention...adjust with dev name changes...
    Apparato->Get_Pointers();

    if ( Trigger_low_on==1 ) Trigger=new TriggerBox();
   

    if ( Wtrk==1 )
    {
        // do tracks or trigger... at least four chamber...
        // for the kpivv experiment we need six chamber. of four planes each.....

        // NA48 experiment    4 chambers
        if ( Cam1!=0&&Cam2!=0&&Cam3!=0&&Cam4!=0&&Mag48!=0 )
        {
            // Na48/1, NA48/2   apparatus

            // in principio si possono trovare piu' tracce ma
            // ne ricostruiamo solo per 6 ....
            Le_Tracce=new Flyline();
            Tracc[0]=new Flytrk();
            Tracc[1]=new Flytrk();
            Tracc[2]=new Flytrk();
            Tracc[3]=new Flytrk();
            Tracc[4]=new Flytrk();
            Tracc[5]=new Flytrk();
            Gout<<"\n Dev NA48  track  done \n";
        }
        // Kpvv   experimento... nuovo apparato per il calcolo della fascio dal gigatrack...
        if ( giga1!=0&&giga2!=0&&giga3 )
        {
            // NA62: Kpivv new apparatus with double spectrometer
//            Trkgiga=new TrackGiga();  // to test
//            Gout<<"\n Dev Trkgiga    done \n";
        }
    }
// here devstraw create...TriggerBox


    if ( FirstStraw!=0 )
    {
// gmpKill

        DevStraw * poistraw=FirstStraw;

        ChambClus[0]=new ClusterStraw ( poistraw );
        poistraw=poistraw->nextstraw->nextstraw->nextstraw->nextstraw;
        ChambClus[1]=new ClusterStraw ( poistraw );
        poistraw=poistraw->nextstraw->nextstraw->nextstraw->nextstraw;
        ChambClus[2]=new ClusterStraw ( poistraw );
        poistraw=poistraw->nextstraw->nextstraw->nextstraw->nextstraw;
        ChambClus[3]=new ClusterStraw ( poistraw );
// generate the track straw pointer.
        if ( Wtrk==1 )Trkstraw = new TrgmpStraw();
        Gout<<"\n Dev NA62  track (gmp)  done \n";


        // generate the track straw pointer.
        //        if( Wtrk==1 )Trkstraw = new TrackStraw();
        //        Gout<<"\n Dev NA62  track  done \n";

        //        ChambClus[0]=new ClusterStraw ( FirstStraw);//  attenzione per test gmp
    }

    Gout<<endl;


    // general random initialitiation:
    //     Correla =0 Inizializzazione fissa
    //     Correla =1 Inizializzazione dipendente dal run
    //     Correla =2 Inizializzazione dipendente dal run ed evento

    if ( Correla==0 ) Pran();
    else Set_Pran();


    Mostra=evento_.Mxev/10;
    if ( Mostra< 10000 ) Mostra=10000;
    if ( Mostra>200000 ) Mostra=200000;


    clockstart = time ( &tck );
    Gout<<"\n\n Starting time: "<< tck<<" ===> "<<ctime ( &clockstart );
    cout<<"\n\n Starting time: "<< tck<<" ===> "<<ctime ( &clockstart ) <<endl;
}
void flyosimuladev ( )

Introduce gli errori sperimentali nei dati geometrici e cinematici relativi a ciascun rivelatore (vedi virtual void DataSmear()) e ne simula in dettaglio il comportamento (procedura virtual int SimulaDev()) se richiesto.

Definition at line 333 of file mainuti.cpp.

{
    Device *pv;
    pv=Apparato;
    while ( pv!=0 )
    {
        if ( pv->escludi==0)
        {
            pv->Reset_RootData();

//            if ( pv->nhit>-1 )
//            {
// si simula in dettaglio il dev e poi si introducono gli errori 
// aggionamento con inversione (DataSmear<-> simulaDev) dal 5/3/2011
                if ( Errori==1 )  pv->SimulaDev();
                if ( Errori==1 )  pv->DataSmear(); 
             
 //           }
        }
        pv=pv->next;
    }


//========================================================
    // ricostruisco le tracce per NA48.....

    if ( Le_Tracce!=0 )
    {
        Le_Tracce->Reset();
        Le_Tracce->Get_Hits_from_Dev();
        Le_Tracce->Find_Tracce();  // creo le tracce:  max six ma si puo' aumentare
        if ( Debugon==1 )
        {
            if ( Tracc[0]!=0 ) Tracc[0]->Spia_Trk();
        }
    }

//========================================================

//  straw chamber track                                 GmpKill

    if ( Trkstraw !=0 )   {
        ChambClus[0]->Get_Cluster();
        ChambClus[1]->Get_Cluster();
        ChambClus[2]->Get_Cluster();
        ChambClus[3]->Get_Cluster();


        Trkstraw->Make_Trk();


    }






    // it is called at the  tracing end
    //------------update special counters ---

    SelRea->Tailsrt+=   SelRea->Tailsrt_done;
    SelRea->Tailong+=   SelRea->Tailong_done;
    evento_.Gen.Itsrt=SelRea->Tailsrt_done;
    evento_.Gen.Itlg= SelRea->Tailong_done;




}
 All Classes Namespaces Files Functions Variables