Changeset 17 in ZHANGProjects for ICOSIM/CPP/trunk/source/CrystalCollimator.cc


Ignore:
Timestamp:
Sep 30, 2014, 11:05:33 AM (10 years ago)
Author:
zhangj
Message:

Added comments...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ICOSIM/CPP/trunk/source/CrystalCollimator.cc

    r15 r17  
    3232
    3333
    34 void CrystalCollimator::collipassCrystal(vector <Particle>& bunch, const double& betgam, const int& pas, string outputpath)
     34void CrystalCollimator::collipassCrystal(vector <Particle>& bunch, const double& betgam, const int& pas, long int& nhit, string outputpath)
    3535{
    36 
     36//pas: number of turns
    3737    //Calculate proton energy
    3838    double Mproton(0.93827231); //rest mass [GeV]
     
    6262
    6363        for (int k(0); k < bunch.size(); ++k) {
    64 
     64            //simulate the particles that are not lost on the previous aperture
     65            if(bunch[k].inabs !=0){   
    6566            sortie  << bunch[k].coordonnees[0][0] << "," << bunch[k].coordonnees[0][2] << "," << bunch[k].coordonnees[0][1] << "," << bunch[k].coordonnees[0][3] << "," << Eproton[k] << endl;
     67            }
    6668        }
    6769
     
    9395   // sim.general(sim, pas, outputpath, NAME, emitx0, emity0,enum, C_rotation, C_aperture, C_offset, C_tilt, Cry_tilt);
    9496   
    95     sim.general(sim, pas, outputpath, Mirror, C_rotation, C_aperture, C_offset, C_tilt, Cry_tilt);
     97    sim.general(sim, pas, nhit, outputpath, Mirror, C_rotation, C_aperture, C_offset, C_tilt, Cry_tilt);
    9698
     99   
     100    //assign the new bunch coordinates after the crystal
     101    for (int k(0); k < bunch.size(); ++k) {
     102      bunch[k].inabs =0 ;
     103    }
     104   
     105   
    97106    ifstream enter;
    98107    string file_in;
     
    105114    } else {
    106115
    107         for (int k(0); k < bunch.size(); ++k) {
     116        for (int k(0); k < bunch.size()-nhit; ++k) {
    108117
    109118            string rest;
     
    120129            getline(enter, rest, ',');
    121130            bunch[k].coordonnees[1][3] = atof(rest.c_str());
    122 
     131           
     132            //particle is not lost (interact) with the crystal
     133            bunch[k].inabs = 1;
     134           
    123135            getline(enter, rest);
    124136            Eproton[k] = atof(rest.c_str());
     137         
    125138        }
    126139
     
    128141    }
    129142
     143   
    130144    vector <double> gamProton;
    131145    vector <double> betProton;
Note: See TracChangeset for help on using the changeset viewer.