Ignore:
Timestamp:
01/28/00 09:19:54 (25 years ago)
Author:
harald
Message:
A new version from JoseCarlosGonzalez. The old routine for random_pointing
was not correct. This one should be okay!!
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Simulation/Detector/Reflector/reflector.cxx

    r347 r348  
    2020//
    2121// $RCSfile: reflector.cxx,v $
    22 // $Revision: 1.8 $
     22// $Revision: 1.9 $
    2323// $Author: harald $
    24 // $Date: 2000-01-28 08:59:49 $
     24// $Date: 2000-01-28 09:19:54 $
    2525//
    2626////////////////////////////////////////////////////////////////////////
     
    795795int Random_Pointing = FALSE;
    796796
     797//@: number of times a shower is going to be processed
     798int nRepeat_Random;
     799
     800//@: number of times a shower is already processed
     801int nRepeated;
     802
    797803//@: maximum random pointing distance
    798804float Random_Pointing_MaxDist; // [radians]
     
    921927  parname[0] = '\0';
    922928
    923   optarg = NULL;
     929  optarg = 0;
    924930  while ( !errflg && ((ch = getopt(argc, argv, COMMAND_LINE_OPTIONS)) != -1) )
    925931    switch (ch) {
     
    945951
    946952  if ( strlen(parname) < 1 )
    947     readparam(NULL);
     953    readparam(0);
    948954  else
    949955    readparam(parname);
     
    11651171    outputfile.write( SIGNATURE, sizeof(SIGNATURE) );
    11661172
     1173  // get random pointing variables
     1174 
     1175  Random_Pointing = get_random_pointing( &Random_Pointing_MaxDist );
     1176
    11671177  // generate a sort of log information
    11681178
    11691179  if ( verbose >= VERBOSE_MINIMAL ) {
     1180    log( SIGNATURE, "Random poi.:       %f\n", Random_Pointing_MaxDist );
    11701181    log( SIGNATURE, "Atmospheric model: %s\n", get_atm_mod() );
    11711182    log( SIGNATURE, "Number of paths:   %d\n", get_num_of_paths() );
     
    11771188
    11781189  get_energy_cuts( &lE, &uE );
     1190
     1191  // get number of times which a shower is going to be used
     1192  // at different pointing directions
     1193  nRepeat_Random = get_repeat_random();   
    11791194
    11801195  /*!@'
     
    12021217    directory = opendir(pathname);
    12031218
    1204     if ( directory == NULL )
     1219    if ( directory == 0 )
    12051220      error( SIGNATURE,
    12061221             "Cannot open directory %s\n", pathname );
     
    12321247        log(SIGNATURE, " * * * READING DATA FROM STDIN * * *\n");
    12331248
    1234       get_stdin_files( 0, lE, uE, TRUE);
     1249      get_stdin_files(0, lE, uE, TRUE);
    12351250
    12361251    }
     
    12461261    //            maximum number is not reached ) )
    12471262
     1263    nRepeated = 0;
     1264
    12481265    while ( (
    1249              ((de = readdir( directory )) != NULL) &&
     1266             ((de = readdir( directory )) != 0) &&
    12501267             (num_cer_files < max_num_cer_files)
    12511268             )
     
    12551272             (num_cer_files < max_num_cer_files)
    12561273             ) ) {
    1257      
     1274        /*
     1275      // increment the number of times this files is used
     1276      nRepeated++;
     1277        */
     1278
    12581279      // if Block > 0, then we wait till a file __DOIT is present
    12591280     
     
    14401461       
    14411462      mcevth.put_times ( stat.get_tfirst(), stat.get_tlast() );
    1442 
     1463       
    14431464      // get direction where the CT is pointing to
    14441465      // (or, better, from when the shower is coming from)
     
    14511472
    14521473      // do we want random pointing (around shower axis) ?
    1453       if ( get_random_pointing( &Random_Pointing_MaxDist ) == TRUE ) {
     1474      if ( Random_Pointing == TRUE ) {
    14541475
    14551476        // we do, then get a random position
     
    19862007        // the photon actually hit the mirror!!
    19872008
     2009       
    19882010        t = t + ((( xm[2] > 0. ) ? -1.0 : +1.0) *
    19892011                 sqrt( SQR(xm[0] - xcut[0]) +
    19902012                       SQR(xm[1] - xcut[1]) +
    19912013                       SQR(xm[2] - xcut[2]) ) / Speed_of_Light_air_cmns);
    1992 
    1993         // add path from the mirror till the camera
     2014                 
     2015        // add path from the mirror till the camera
    19942016
    19952017        t = t + sqrt( SQR(xcutCT[0] - xcam[0]) +
     
    22122234
    22132235  delete [] ct_Focal;       
    2214   ct_Focal = NULL;
     2236  ct_Focal = 0;
    22152237
    22162238  // delete reflectivity table
     
    22212243 
    22222244  delete [] Reflectivity;   
    2223   Reflectivity = NULL;
     2245  Reflectivity = 0;
    22242246
    22252247  // delete mirrors' data table
     
    22302252 
    22312253  delete [] ct_data;
    2232   ct_data = NULL;
     2254  ct_data = 0;
    22332255}
    22342256//!@}
     
    34923514{
    34933515  float distance;
    3494   float it, ip,Nit;
     3516  float it, ip;
    34953517  float sin_theta, cos_theta;
    34963518  float sin_newtheta, cos_newtheta;
    34973519  float sin_iphi, cos_iphi;
    34983520  float iphi;
    3499   float range_aux;
    3500   int i;
    3501 
    3502   //Random position of the CT. It is the distance
    3503   //between shower axis and CT position and its 
    3504   //distribution follows sin(it).
    3505 
    3506   range_aux=1.0-sin(M_PI/2-range);
    3507   Nit = RandomNumber * range_aux;
     3521
     3522  // for the moment, we only simulate an uniform distribution,
     3523  // since our theta distribution in the generation of events is
     3524  // already uniform for hadrons, which are the main targets for
     3525  // using this option
     3526
     3527  it = RandomNumber * range;
    35083528  ip = RandomNumber * 2.0 * M_PI;
    3509   it = M_PI/2-asin((1.0-Nit));
    3510 
    3511   sin_theta = sin(theta);
    3512   cos_theta = cos(theta);
    3513 
    3514   cos_newtheta = cos_theta*cos(it) - sin_theta*sin(it)*cos(ip);
    3515   *newtheta = acos( cos_newtheta );
    3516   sin_newtheta = sin( *newtheta );
    3517  
    3518   if(theta!=0){
    3519     sin_iphi = sin(it)*sin(ip)/sin_newtheta;
    3520     cos_iphi = ((cos(it)-cos_newtheta*cos_theta)/(sin_newtheta*sin_theta));
     3529
     3530  if ( theta == 0.0 ) {
     3531
     3532    *newtheta = it;
     3533    *newphi = ip;
     3534
     3535  } else {
     3536   
     3537    sin_theta = sin(theta);
     3538    cos_theta = cos(theta);
     3539
     3540    cos_newtheta = cos_theta*cos(it) + sin_theta*sin(it)*cos(ip);
     3541    *newtheta = acos( cos_newtheta );
     3542    sin_newtheta = sin( *newtheta );
     3543   
     3544    sin_iphi = sin(it)*sin(ip) / sin_newtheta;
     3545    cos_iphi = (( cos(it) - cos_newtheta * cos_theta ) /
     3546                ( sin_newtheta * sin_theta ));
    35213547   
    35223548    iphi = atan2( sin_iphi, cos_iphi );
     3549   
     3550    *newphi = phi + iphi;
     3551
    35233552  }
    3524   else iphi=ip;
    3525 
    3526   *newphi = phi + iphi;
    35273553
    35283554  return( it );
     
    35363562//!@{
    35373563//
    3538 // Revision 1.3  2000/01/03 12:41:26  harald
    3539 // There was a small mistake with +/- signs in the prevois versions. This
    3540 // line was founded by Jose Carlos. His remark is following:
    3541 //
    3542 // Look for the comment I include here in this block: you will see that
    3543 // now the following expression has a +- sign, where before it was only
    3544 // + (or -, I don't remember, but only one)
    3545 //
    3546 // Revision 1.2  1999/11/01 11:05:54  harald
    3547 // Small changes to comile the reflector program under linux.
    3548 // (Different use of NULL on DECalphas-osf1 and on linux)
    3549 //
    3550 // Revision 1.1.1.1  1999/10/29  07:00:33  harald
    3551 // This is the startpoint for the futher development of the Reflector program
    3552 // of Jose Carlos. For all developments use this CVS-controlled directory.
     3564// $Log: not supported by cvs2svn $
     3565// Revision 1.20  2000/01/27  10:47:54  gonzalez
     3566// JAN2000-STABLE
     3567//
     3568// Revision 1.19  1999/11/19  20:52:31  gonzalez
     3569// *** empty log message ***
    35533570//
    35543571// Revision 1.18  1999/10/05  11:11:12  gonzalez
Note: See TracChangeset for help on using the changeset viewer.