alcap-org / g4sim

Simulation toolkit based on Geant4 and ROOT
http://wuchen1106.github.io/g4sim/
2 stars 2 forks source link

Use TURTLE Data for Input Beam Distribution #43

Closed AndrewEdmonds11 closed 10 years ago

AndrewEdmonds11 commented 10 years ago

I've had a look into this from the output file that John gave me yesterday.

In the file, there is only a bunch of text histograms like so:

1Histogram No  1                        
 distribution of    x in cm                           0.000 m    from the target, flag at       32.428 m   

           interval                              scale factor.. 100 X"s equal  0.562E+04 entries.

 less than    -0.500       0.0                                                                                                       

    -0.500 :  -0.400    3694.0   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX                                   
    -0.400 :  -0.300    4850.0   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX              
    -0.300 :  -0.200    5306.0   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX      
    -0.200 :  -0.100    5529.0   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  
    -0.100 :   0.000    5620.0   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     0.000 :   0.100    5604.0   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 
     0.100 :   0.200    5347.0   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX     
     0.200 :   0.300    5053.0   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX           
     0.300 :   0.400    4733.0   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX                
     0.400 :   0.500    3289.0   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX                                          

 more than     0.500       0.0                                                                                                       

          total number of entries =     49025     including underflow and overflow.
           center =  -0.006   RMS half width =   0.267

 Histogram No  1                        
 distribution of    x in cm                           0.000 m    from the target, flag at       32.428 m 

where the first two columns are the bin limits and the third column is the number of entries in that bin.

There are histograms for x, x', y and y' for several distances "from target". I've assumed that we want the one at 0m and that is the end of the beam pipe.

I have converted these to ROOT histograms but am not sure how suitable they are since the bins are too wide.

We can't really draw random values from the histograms because we will just end up with an unrealistic distribution and I have tried fits to a Gaussian (shown below), which don't alway look that nice...

gausfit_xangle

gausfit_xposition (for this one, I know that there are 0 entries in the underflow and overflow bins in the tutrtle data so we might get a better fit)

gausfit_yangle (I guess that a Gaussian isn't suitable here)

gausfit_yposition

Any ideas?

jrquirk commented 10 years ago

Draw a random number from the histogram then add another random number flatly distributed between -binwidth/2 and +binwidth/2? The histograms themselves should be fine enough for this to work.

Also, I think you're right about the 0m thing but we should check that the distance isn't meters-away-from-production-target with Peter.

AndrewEdmonds11 commented 10 years ago

Draw a random number from the histogram then add another random number flatly distributed between -binwidth/2 and +binwidth/2?

I think this is what TH1F::GetRandom() essentially does. My worry is that when I use this with x-position and fill a histogram that has 10 times as many bins, I get this:

random_10m_xpos

and we can see the binning of the original histogram. I guess I could try to linearly interpolate between bins. Or are bin widths of 0.1cm good enough anyway and I don't need to worry?

AndrewEdmonds11 commented 10 years ago

The other option is to use the mean and RMS of the histograms (which also match the values given in the TURTLE output)

benkrikler commented 10 years ago

How about using the fitted gaussians for the x, x' and y distributions since it looks like a reasonable model for those values and then for the y-direction use a flat distribution over the range of angles in the histogram?

AndrewEdmonds11 commented 10 years ago

How about using the fitted gaussians for the x, x' and y distributions since it looks like a reasonable model for those values and then for the y-direction use a flat distribution over the range of angles in the histogram?

Yes, I think that's what I'm going to do. So now it's just a case of transforming the coordinates correctly.

AndrewEdmonds11 commented 10 years ago

Everything working and merged in

AndrewEdmonds11 commented 10 years ago

This has now changed slightly - see my presentation in elog:204