// // ******************************************************************** // * License and Disclaimer * // * * // * The GAMOS software is copyright of the Copyright Holders of * // * the GAMOS Collaboration. It is provided under the terms and * // * conditions of the GAMOS Software License, included in the file * // * LICENSE and available at http://fismed.ciemat.es/GAMOS/license .* // * These include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GAMOS collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the GAMOS Software license. * // ******************************************************************** // /*================================================================== PLOTPHSP UTILITIES LIBRARY Juan Diego Soler Pulido email: juandiego.soler@ciemat.es Madrid, Spain December 2006 Daniel P. A. 05/2008 Pedro Arce 11/2009 =================================================================*/ #include #include #include #include #include #include #include #include "EGSPhspParticle.hh" EGSPhspParticle::EGSPhspParticle(FILE* , std::string ) { theFilePointer = 5*sizeof(char)+2*sizeof(int)+3*sizeof(float)+3; } EGSPhspParticle::~EGSPhspParticle() { } //------------------------------------------------------------------- int EGSPhspParticle::RefreshParticle(FILE* file, long number) { float aux; int reset_phsp; int a1; long step; step = sizeof(unsigned int) + 6*sizeof(float); theParticleNumber = number; (void) fseek(file,theFilePointer,SEEK_SET); a1 = fread(&theLatch,sizeof(unsigned int),1,file); a1 &= fread(&theEnergy,sizeof(float),1,file); a1 &= fread(&thePosX,sizeof(float),1,file); thePosX *= 10.; a1 &= fread(&thePosY,sizeof(float),1,file); thePosY *= 10.; a1 &= fread(&theDirU,sizeof(float),1,file); a1 &= fread(&theDirV,sizeof(float),1,file); a1 &= fread(&theWeight,sizeof(float),1,file); if(a1){ reset_phsp = false; theEnergy = fabs(theEnergy); if(!CheckIntegrity(theParticleNumber)){ printf("Phase space problem on record %d!\n",int(theParticleNumber)); return true; } // calculate theDirW aux = theDirU*theDirU+theDirV*theDirV; if (aux<=1.0) theDirW = (float) sqrt((float)(1.0-aux)); else{ aux= (float)sqrt((float)aux); theDirU/=aux; theDirV/=aux; theDirW=0.0f; } if(theDirW < 0.0f) theDirW *= -1.0f; // obtain npass from theLatch if ((theLatch & 0x80000000) != 0){ // printf("Multiple crosser\n"); theNPass=1; theLatch &= 0x7FFFFFFF; } else theNPass=0; // obtain q from theLatch if((theLatch & 0x40000000) != 0){ theCharge = -1; theLatch &= 0xBFFFFFFF; } else if ((theLatch & 0x20000000) != 0){ theCharge = +1; theLatch &= 0xDFFFFFFF; } else theCharge = 0; theFilePointer += step; int MAX_PRINT = 10; if(theParticleNumber <= MAX_PRINT){ std::cout << "# " <