Changeset 17 in ZHANGProjects for ICOSIM/CPP/trunk/source/simcrys.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/simcrys.cc

    r16 r17  
    576576* original crystal routine
    577577* *******************************************************************************/
    578 void SimCrys::general(SimCrys& sim, const int& pas, string outputpath, double Mirror, double C_rotation, double C_aperture, double C_offset, double C_tilt, double Crystal_tilt)
     578void SimCrys::general(SimCrys& sim, const int& pas, long int& nhit, string outputpath, double Mirror, double C_rotation, double C_aperture, double C_offset, double C_tilt, double Crystal_tilt)
    579579{
    580580    srand ( time(NULL) );
     
    659659
    660660
    661 
     661   
     662     
     663     
    662664    //----------------------------------END OF INITATING REFERNENTIAL PARAMETERS-------------------------------------------------------------------------
    663665    c_length = crys.Cry_length;
     
    692694       * xmin=x-, xmax=x+, etc. from the input file
    693695       */
    694      long int    nhit    = 0;
     696   
     697
     698      //initialize particle variables
     699      part.n_part = 0;
     700      part.nabsorbed = 0;
     701      part.namor = 0;
     702      part.nchann = 0;
     703      part.ndechann = 0;
     704      part.nout =0;
     705      part.nvcapt = 0;
     706      part.nvrefl = 0;
     707      part.nhit = 0;
     708      nhit    = 0;
    695709    double fracab  = 0;
    696710  //  int   n_chan  = 0;          // valentina :initialize to zero the counters for crystal effects
     
    748762      while (!entree.eof()) {
    749763        count = count + 1;
     764       
     765        //particle hit the crystal or not
     766        bool hitflag = false;
     767         
    750768       
    751769        getline(entree, rest, ',');
     
    927945              s_impact = s_in0;       //!(for the first impact)
    928946             
    929               if(1){
     947              if(0){
    930948                cout<<"hit the cry entrance face"<<endl;
    931949                cout<<"impact at s = "<< s_impact<< ",  x = "<<x_in0<<endl;
     
    10621080              //cout<<"----------------------1111111111111111111111111-----------------"<<endl;
    10631081             
    1064        
     1082           if(layerflag == 0){
     1083              part.namor = part.namor + 1;     /////////////COUNT/////////////
     1084              part.effet = 2;
     1085              }
     1086             
    10651087              if (strncmp(Proc,"out",3)==0)
    10661088                crossing  = false;
     
    10691091             
    10701092              if (crossing == true){
    1071                 nhit = nhit + 1;
     1093                hitflag = true;
     1094                nhit = nhit + 1;
     1095                part.nhit = nhit;
    10721096        //      lhit = 100000000*ie + ITURN;
    10731097                impact = x_in0;           
     
    12611285                      xp_in0 = xp_shift;
    12621286                    }                 ////////////////////////// fin IF NUMERO 17//////////////////
    1263                    
     1287                    hitflag = true;
    12641288                    nhit = nhit + 1;
     1289                    part.nhit = nhit;
    12651290                    //lhit = 100000000*ie + ITURN;
    12661291                    impact = x_in0;           
     
    13391364
    13401365
    1341             nabs = 0;
     1366            nabs = 0;   //particle lost or not lost.....
    13421367            part.effet = nabs;
    13431368            //cout<< "debug - S Coll RF 2" ,  s_rot <<endl;
     
    13751400             part.nvcapt = part.nvcapt + 1;     /////////////COUNT/////////////
    13761401            part.effet = 6;}
     1402             if(strncmp(Proc,"absorbed",8==0)){
     1403             part.nabsorbed = part.nabsorbed +1;
     1404              part.effet = 7;
     1405            }
     1406             /*           
     1407 if (PROC(1:3).eq.'pne')
     1408                 PROC_dan=7
     1409             if (PROC(1:3).eq.'ppe')
     1410                 PROC_dan=8
     1411               if (PROC(1:4).eq.'diff')
     1412                 PROC_dan=9
     1413               if (PROC(1:4).eq.'ruth')
     1414                 PROC_dan=10
     1415             */
     1416   
    13771417           
    13781418              //  ?????????????????????????????????????
     
    14711511          av_pc1 = av_pc1 + part.PC;
    14721512
    1473 
     1513      if(0){
    14741514          cout<<"  X apres :"<<part.x<<"  XP apres :"<<part.xp<<"  Y apres :"<<part.y<<"  YP apres :"<<part.yp<<"  PC apres :"<<part.PC<<endl;
    14751515          //cout<<endl;
     1516      }
     1517      //only record the particles that hit the collimator.
     1518      if(hitflag != true){
    14761519          //sortieIco.setf(ios::scientific);
    1477           sortieIco << part.x << "," << part.y << "," << part.xp << "," << part.yp << "," << part.PC << endl;
     1520          sortieIco << part.x << "," << part.y << "," << part.xp << "," << part.yp << "," << part.PC  << endl;
    14781521          //}//end of for....
    1479          
     1522      }
     1523     
    14801524        }
    14811525      } //End of while
     
    15251569    file_out(pas, outputpath);
    15261570   
     1571    if(1){
     1572      cout << "number of particles before the crystal: " << count<< endl;
     1573      cout << "number of particle hit the crystal: " << part.nhit << endl;
     1574      cout << "number of particles after the crystal: " << count - part.nhit << endl;
     1575    }
    15271576    //cout<<endl;
    15281577    //cout<<endl;
     
    16671716    cout << "N.OUT :" << part.nout << endl;
    16681717    cout << "N.VREFLECTION :" << part.nvrefl << endl;
    1669     cout << "N.VCAPTURE :" << part.nvcapt << endl;
     1718    cout << "N.VCAPTURE:" << part.nvcapt << endl;
     1719    cout << "N.ABSORBED: "<< part.nabsorbed << endl;
    16701720
    16711721    //cout << "Si la somme ne donne pas le nbre de part., c est normale !! En effet, il est possible que plusieurs evenement se produisent!!!";
     
    16881738        out << "Crystal Curved Length [m] :" << crys.Cry_length << endl;
    16891739        out << "Crystal Curvature Radius [m] :" << crys.Rcurv << endl;
    1690         out << "Crystal Bending Angle [urad] :" << crys.cry_bend << " , " << crys.Cry_length / crys.Rcurv << endl;
     1740        out << "Crystal Bending Angle [urad] :" << crys.cry_bend << " , " << 1e6*crys.Cry_length / crys.Rcurv << endl;
    16911741        out << "Critical Radius :" << crys.Rcrit << endl;
    16921742        out << "Ratio :" << crys.ratio << endl;
     
    17021752        out << "N.OUT :" << part.nout << endl;
    17031753        out << "N.VREFLECTION :" << part.nvrefl << endl;
    1704         out << "N.VCAPTURE :" << part.nvcapt << endl << endl << endl;
    1705 
     1754        out << "N.VCAPTURE :" << part.nvcapt << endl ;
     1755        out << "N.ABSORBED: "<< part.nabsorbed << endl;
     1756        out << "N. of particles that hit the crystal collimator: " << part.nhit << endl;
     1757        cout << endl;
     1758        cout << endl;
     1759       
    17061760        out.close();
    17071761    }
Note: See TracChangeset for help on using the changeset viewer.