亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? monte carlo.txt

?? MonteCarlo仿真的C++源碼
?? TXT
字號:
Monte Carlo Simulation C++ Source Code
This source code was compiled and run on a Sun Sparc Ultra170 running Solaris
2.5. The GNU C compiler gcc version 2.7 was used by calling g++ so that the C++
code would be recognized. The code (named spectrum.cc) was compiled with the
command:

g++ -o spectrum spectrum.cc

The math.h library must be linked in order for the program to successfully run.
This may require the -lm option on some systems.

The minimum information needed to run the program is input as:

spectrum voltage attenuation photoelectrons

The total supply voltage is given by voltage. The attenuation of the
photomultiplier signal is given by attenuation, and is equal to the factor by
which the signal is to be divided. The average number of photoelectrons ejected
by the photocathode is
given by photoelectrons. More options are available by entering a non-zero
number after the other command line parameters. The user is then prompted for a
threshold setting (default is zero), which is multiplied by ten to get the ADC
channel for the
cutoff (the multiplication by ten is convenient because the data output by the
program was rebinned by a factor of ten before being analyzed). The user is then
prompted for a gain factor (default is zero) to fit the program to individual
8854 tubes
because the have different gains. The gain factor is given in percent divided by
ten by which the gain is to be scaled, for example an input of 10 increases the
simulated gain by 100% and an input of -1 decreases the gain by 10%.

A directory called ``newspec'' must be created as a subdirectory of the
directory in which the program is run before running the program. All output
files are put in this directory. Each run of the program results in 31 files.
The format of the file
names is:

voltage_attenuation_photoelectrons_number

The last part of the file name indicates the number of initial photoelectrons
represented in that particular histogram file. The file ending in 0 is the sum
of all other histograms, the spectrum actually seen if the experiment was run.
The histograms
for specific numbers of initial photoelectrons were created to analyze the
effect of the algorithm used to simulate the low charge events on larger numbers
of photoelectrons and to look at the relations between mean and standard
deviations of the
individual peaks without interference from other peaks. The output of the
program can be analyzed in any program that can import text and make histograms.
The file format is one channel per line (200 channels at 2.5 pC per channel).


#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#include <sys/types.h>
#include <time.h>
#include <math.h>
#include <String.h>

//DEFINES

//number of bins (in x direction)
#define BINS 200

//maximum number of photoelectrons considered
#define MAX_PE 30

//how many events to simulate
#define NUM_EVENTS 40000

//FUNCTION PROTOTYPES

//return a random integer between lower and upper
int myRandInt(int lower, int upper);

//return a random double between lower and upper
double myRandDouble(double lower, double upper);

//return the value of the poisson distribution with
//average value at x
double myPoisson(int x, double avg);

//return value of gauss distribution with mean,
//standard deviation  at x
double myGauss(double x, double mean, double stdev);

//return x! (return is a double to be able to handle
//large numbers)
double factorial(int x);

//return a random value conforming to a poisson
//distribution
int poissonBin(double avg, int xMax, double yMax);

//return a random value conforming to a gauss
//distribution
double gaussBin(double mean, double stdev, double lc);

//calculates unattenuated mean from voltage
double myMean(double voltage);

//calculates unattenuated stdev from voltage
double myStdev(double voltage);

//calculates low charge events for a gauss with mean
double myLowC(double mean);

//returns the value attenuated by att
double myAtt(double value, double att);

//Converts an integer to a String
String myIntToString(int x);

//Converts a double to string, accurate to tenths place
String myTenthsToString(double x);

//Converts a String to a double
double myStringToDouble(String num);

//for optimization calculates the highest x value to
//guess in the poisson
int maxPoissonX(double avg);

//for optimization calculates the highest y value to
//guess in the poisson
double maxPoissonY(double avg);

//rounding integer routine
int myRound(double x);

//MAIN

/*This is the main part of the program.  There are 3
 required command line parameters and one optional.
 They are [voltage] [attenuation] [average number of
 photoelectrons] [editor mode (non zero value)](opt.)
 If the last parameter is omitted a default value of
 zero is used.
  */

void main(int argc, char *argv[]) {
  if(argc < 4) {
    cerr << "Error: too few parameters\n";
    exit(-1);
  }

  srand48(time(NULL));

  /*make 2 D array to hold all of the info to be written
    to files (spectra) there are MAX_PE+1 different spectra
    (one for the combined spectra) and each has BINS number
    of bins
    */

  int spectra[MAX_PE+1][BINS];
  for(int i=0; i<MAX_PE+1; i++)
    for(int j=0; j<BINS; j++)
      spectra[i][j]=0;

  /*
    gf is gain factor, gain factor scales the average and
    stdev. linearly in an attempt to account for variations
    in the gain of the tubes.
  */

  double voltage, att, avgpe, opt;

  opt=0;

  voltage = myStringToDouble(argv[1]);
  att = myStringToDouble(argv[2]);
  while(att <= 0) {
    cout << "Please enter a positive attenuation factor: ";
    cin >> att;
  }
  avgpe = myStringToDouble(argv[3]);

  if(argc > 4)
    opt=myStringToDouble(argv[4]);

  double thresh=0,gf=0;

  if(opt !=0){
    cout << "\n***Entering Option Editing Mode***\n\n"
         << "Enter the threshold (ADC Channel/10)(default=0):";
    cin >> thresh;
    cout << "Enter the gain factor(default=0):";
    cin >> gf;
  }

  double stdev = myStdev(voltage);
  double mean = myMean(voltage);
  int poissonX = maxPoissonX(avgpe);
  double poissonY = maxPoissonY(avgpe);

  /*adjust mean and stdev*/

  mean = mean + gf*mean;
  stdev = stdev + 0.34*gf*stdev;

  /*get Low Charge Fraction before mean is attenuated*/

  double lc=myLowC(mean);

  /*attenuate mean and stdev*/

  mean=myAtt(mean,att);
  stdev=myAtt(stdev,att);

  for(int i=0; i<NUM_EVENTS;) {

    int numPE = poissonBin(avgpe, poissonX, poissonY);

    double tmpGauss=0.0;
    for(int j=0; j<numPE; j++) {
      tmpGauss += gaussBin(mean,stdev,lc);

    }

    if(tmpGauss>=thresh) {
      int gauss = myRound(tmpGauss);
      if(gauss > BINS-1)
        gauss=BINS-1;
      spectra[numPE][gauss]++;
      i++;
    }
  }


  for(int i=0; i<BINS; i++)
    for(int j=1; j<MAX_PE+1; j++)
      spectra[0][i] += spectra[j][i];


  //output is "newspec/[voltage]_[attenuation]_[avgPE]"
  //all to tenths place

  for(int i=0; i<MAX_PE+1; i++) {
    ofstream file_out;
    String name;
    name = "newspec/";
    name += myTenthsToString(voltage);
    name += "_";
    name += myTenthsToString(att);
    name += "_";
    name += myTenthsToString(avgpe);
    name +="_";
    name += myIntToString(i);
    file_out.open(name);

    for(int j=0; j<BINS; j++)
      file_out << spectra[i][j] << endl;
    file_out.close();
  }

}


int myRandInt(int lower, int upper) {
  int done=0;
  int result;
  while(!done) {
    result = int((upper+1-lower)*drand48() + lower);
    if(result != upper+1)
      done=1;
  }
  return result;
}


double myRandDouble(double lower, double upper) {
  return (upper-lower)*drand48() + lower;
}

double myPoisson(int x, double avg) {
  return pow(avg,x)*exp(-avg)/factorial(x);
}

double myGauss(double x, double mean, double stdev) {
  return exp(-0.5*pow((mean-x)/(stdev),2));
}

double factorial(int x) {
  double result=1;
  for(int i=x; i>1; i--)
    result = result*i;
  return result;
}

int poissonBin(double avg, int xMax, double yMax) {
  int done=0;
  int x;
  while(!done) {
    double y = myRandDouble(0,yMax);
    x = myRandInt(0,xMax);
    if(y < myPoisson(x,avg))
      done=1;
  }
  return x;
}


double gaussBin(double mean, double stdev, double lc) {
  int done=0;
  double x;
  while(!done) {
    double y = myRandDouble(0,1);
    x = myRandDouble(0,mean+6*stdev);

    if((x<mean) && (y<lc))
      done=1;

    if(y < myGauss(x,mean,stdev))
      done=1;
  }
  return x;
}

//fit from data
double myMean(double voltage) {
  return exp(0.00379*voltage-6.45);
}

//fit from data
double myStdev(double voltage) {
  return exp(0.0034*voltage-7.05);
}

//fit to data
double myLowC(double mean) {
  return (0.35 - 0.024*exp(0.0091*mean));
}

double myAtt(double value, double att) {
  return value/att;
}


String myIntToString(int x) {
  String result;

  if(x/10==0) {
    result = char('0'+x);
  }
  else {
    result = myIntToString(x/10);
    result += char('0' + x%10);
  }
  return result;
}


String myTenthsToString(double x) {
  int tmp = int(x*10);
  String result = myIntToString(tmp);
  char last = result[result.length()-1];
  result[result.length()-1]='.';
  result += last;
  return result;
}

double myStringToDouble(String num) {
  int decimalq=0;
  int power=-1;
  double result=0;
  for(int i=0; i<num.length(); i++) {
    if(num[i]=='.')
      decimalq=1;
    else if(!decimalq)
      result=10*result + double(num[i]-'0');
    else {
      result=result + double(num[i]-'0')*pow(10,power);
      power--;
    }
  }
  return result;
}

int maxPoissonX(double avg) {
  double maxY = maxPoissonY(avg);
  int i=0;
  for(i = int(avg)+1; (myPoisson(i,avg) > 0.001*maxY)
   && (i<MAX_PE); i++);
  return i;
}


double maxPoissonY(double avg) {

  int tmp = int(avg);
  double max = 0.0;
  int i=tmp-1;

  if(i < 0)
    i=0;
  for(i; i<=tmp+1; i++)
    if(myPoisson(i,avg) > max)
      max = myPoisson(i,avg);
  return max;
}

int myRound(double x) {
  int result = int(x);
  if( (x - result) > 0.5 )
    result++;
  return result;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产不卡一区视频| 亚洲天天做日日做天天谢日日欢| 一区二区欧美国产| 欧洲一区在线电影| 香蕉久久夜色精品国产使用方法| 91成人免费网站| 视频一区二区中文字幕| 日韩丝袜情趣美女图片| 国产精品综合在线视频| 亚洲天堂av一区| 欧美日韩国产小视频在线观看| 久热成人在线视频| 国产亚洲精久久久久久| 91女神在线视频| 日韩av一区二区在线影视| 久久久综合精品| 91麻豆精品视频| 天堂在线亚洲视频| 国产拍揄自揄精品视频麻豆| 欧美在线视频日韩| 久久99精品久久久久婷婷| 国产精品第四页| 欧美一区二区视频在线观看| 成人av在线电影| 日本一不卡视频| 国产精品麻豆99久久久久久| 欧美人与性动xxxx| 成人午夜在线视频| 天天做天天摸天天爽国产一区| www久久精品| 欧美日韩精品是欧美日韩精品| 国产精品66部| 天天操天天干天天综合网| 国产丝袜美腿一区二区三区| 在线观看中文字幕不卡| 精品无码三级在线观看视频 | 欧美激情一区在线观看| 欧美精三区欧美精三区| 国产成人亚洲综合a∨婷婷| 亚洲成人精品在线观看| 国产精品欧美一区二区三区| 日韩欧美国产成人一区二区| 日本道色综合久久| 国产91精品一区二区麻豆网站| 日韩电影免费在线看| 一区二区三区国产豹纹内裤在线| 久久午夜电影网| 3d动漫精品啪啪| 欧美综合一区二区| 成人免费高清视频在线观看| 麻豆免费精品视频| 亚洲一二三四区| 成人欧美一区二区三区在线播放| 精品少妇一区二区| 欧美精品久久久久久久久老牛影院| 97精品久久久午夜一区二区三区 | 精品国产在天天线2019| 在线视频国内自拍亚洲视频| 成人爱爱电影网址| 国产综合色产在线精品| 麻豆国产一区二区| 日本不卡1234视频| 欧美一级国产精品| 欧美私模裸体表演在线观看| 91香蕉视频mp4| 成人视屏免费看| 韩国av一区二区三区在线观看| 奇米色一区二区三区四区| 亚洲高清久久久| 一区二区三区中文字幕精品精品 | 日韩视频不卡中文| 欧美日韩国产精品成人| 欧美美女激情18p| 99麻豆久久久国产精品免费优播| 久久电影网站中文字幕| 亚洲综合小说图片| 亚洲欧美日本在线| 亚洲精品日韩综合观看成人91| 欧美国产精品中文字幕| 国产精品国产三级国产有无不卡| 国产女人18水真多18精品一级做 | 欧美日韩国产区一| 欧美日韩日日骚| 欧美伊人久久久久久久久影院| 色一情一乱一乱一91av| 色综合咪咪久久| 在线亚洲人成电影网站色www| 在线视频国内一区二区| 欧美日韩国产精选| 欧美变态tickling挠脚心| 精品国产乱码久久久久久1区2区 | 中文久久乱码一区二区| 国产精品乱人伦中文| 亚洲色图制服丝袜| 亚洲五码中文字幕| 捆绑调教美女网站视频一区| 国产一区二区视频在线| 91在线小视频| 99久久伊人久久99| 色婷婷精品久久二区二区蜜臂av| 色婷婷久久久久swag精品| 欧美日韩三级一区| 日韩精品一区二区三区在线 | 欧美成人欧美edvon| 久久综合九色综合欧美98| 久久免费美女视频| 国产精品久久久久永久免费观看| 一区二区三区四区在线| 首页国产欧美久久| 国产盗摄视频一区二区三区| 97久久精品人人做人人爽| 欧美日韩视频专区在线播放| 久久综合精品国产一区二区三区| 中文字幕一区av| 亚洲成a人v欧美综合天堂下载| 久久精品噜噜噜成人av农村| 成人国产精品免费观看| 欧美群妇大交群的观看方式| 精品国产乱码久久久久久闺蜜 | 亚洲色图.com| 免费成人在线影院| 99久久99久久免费精品蜜臀| 欧美日韩成人一区| 国产女人18水真多18精品一级做| 亚洲永久免费av| 国产很黄免费观看久久| 欧美色综合久久| 日本一区二区视频在线观看| 午夜激情综合网| 成人a级免费电影| 日韩精品一区二区三区蜜臀| 亚洲欧美视频在线观看| 加勒比av一区二区| 欧美日韩一区二区不卡| 中文字幕精品一区二区三区精品 | 久久综合五月天婷婷伊人| 一级特黄大欧美久久久| 成人免费看的视频| 欧美变态口味重另类| 亚洲国产综合91精品麻豆| 成人免费看片app下载| 亚洲精品一区二区三区在线观看| 一区二区三区四区蜜桃| www.性欧美| 久久亚洲捆绑美女| 奇米一区二区三区| 欧美日韩综合在线| 亚洲精品视频观看| 成人高清av在线| 久久精品日韩一区二区三区| 免费成人深夜小野草| 欧美日韩一区二区电影| 一区二区三区产品免费精品久久75| 国产成人超碰人人澡人人澡| 亚洲精品在线免费播放| 秋霞国产午夜精品免费视频| 欧美肥妇毛茸茸| 亚洲福利视频一区二区| 在线观看不卡视频| 一区二区三区中文字幕精品精品 | 国产精品影视在线| 精品国产乱码久久久久久1区2区| 奇米一区二区三区| 欧美一区二区三区免费观看视频| 亚洲自拍欧美精品| 91福利精品视频| 一区二区三区在线观看国产| 91美女片黄在线观看| 国产精品久久久久久一区二区三区 | 欧洲精品一区二区| 尤物av一区二区| 91色.com| 亚洲成va人在线观看| 91麻豆精品国产91久久久更新时间| 亚洲成年人网站在线观看| 欧美福利一区二区| 美女诱惑一区二区| 精品国免费一区二区三区| 国产精品资源在线| 中文字幕成人av| 91网页版在线| 亚洲国产综合色| 欧美一级精品大片| 国产精品91xxx| 亚洲日本在线a| 91一区二区三区在线播放| 亚洲综合视频在线| 欧美三级三级三级| 久久爱www久久做| 中文字幕国产一区二区| 91麻豆产精品久久久久久 | 亚洲精品在线观看网站| 国产91精品在线观看| 亚洲欧美另类在线| 欧美日韩高清不卡| 国产精品中文欧美| 一区二区三区日韩在线观看| 欧美丰满美乳xxx高潮www| 国产综合色在线| 又紧又大又爽精品一区二区|