Ignore:
Timestamp:
10/13/04 18:05:05 (20 years ago)
Author:
moralejo
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Simulation/Detector/Camera
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx

    r5268 r5269  
    2121//
    2222// $RCSfile: camera.cxx,v $
    23 // $Revision: 1.73 $
     23// $Revision: 1.74 $
    2424// $Author: moralejo $
    25 // $Date: 2004-10-13 14:28:59 $
     25// $Date: 2004-10-13 17:05:05 $
    2626//
    2727////////////////////////////////////////////////////////////////////////
     
    238238static  float Spot_y=0.0;
    239239static  float Spotsigma=0.0;
    240 
    241 static  int CalibrationRun = 0;
    242240
    243241 
     
    717715  // get filenames
    718716
    719   CalibrationRun = 1;
    720   if (! CalibrationRun)
     717  if (! is_calibration_run())
    721718    for(int ict=0;ict<ct_Number;ict++)
    722719      {
     
    16821679
    16831680
    1684   if (CalibrationRun)
     1681  if (is_calibration_run())
    16851682    {
    16861683      DoCalibration(Fadc_CT, Trigger_CT, camgeom, nsb_trigresp, nsb_fadcresp,
     
    44554452{
    44564453
    4457   int ntshow = 0;
     4454  int nevent = 0;
     4455  int maxevents;
    44584456  int lons_return;
    44594457
     
    44644462  float timefirst = 0.;
    44654463  float timelast = 0.;
     4464 
     4465  float lambda, sigma_lambda, phot_per_pix, sigma_time;
     4466  UInt_t *first_pixel, *last_pixel;
     4467  int selected_pixel;
     4468
     4469  // Get parameters of the calibration:
     4470
     4471  get_calibration_properties( &lambda, &sigma_lambda, &phot_per_pix,
     4472                              &sigma_time, &maxevents, &selected_pixel);
     4473
     4474  first_pixel = new UInt_t[ct_Number];
     4475  last_pixel  = new UInt_t[ct_Number];
     4476
     4477  for (int ict = 0; ict < ct_Number; ict++)
     4478    {
     4479      if (selected_pixel < 0)
     4480        {
     4481          first_pixel[ict] = 0;
     4482          last_pixel[ict]  = ((MGeomCam*)(camgeom.UncheckedAt(ict)))->GetNumPixels()-1;
     4483        }
     4484      else
     4485        first_pixel[ict] = last_pixel[ict] = selected_pixel;
     4486    }
     4487
    44664488
    44674489  TArrayC *fadcValues;     //@< the analog Fadc High gain signal for pixels
     
    44764498  float *pheinpix = new float [ct_NPixels];
    44774499
    4478   for (int calevent = 0; calevent < 1; calevent++)
     4500  for (int calevent = 0; calevent < maxevents; calevent++)
    44794501    {
    44804502      //
     
    44934515        }
    44944516
    4495       ntshow++;
    4496 
    4497       if((ntshow+1)%100 == 1)
    4498         log(SIGNATURE, "Event %d\n", ntshow);
     4517      nevent++;
     4518
     4519      if((nevent+1)%100 == 1)
     4520        log(SIGNATURE, "Event %d\n", nevent);
    44994521       
    45004522      // Produce the photoelectrons
    4501       float phot_per_pix = 100.;
    45024523      for(int ict = 0; ict < ct_Number; ict++)
    45034524        produce_calib_phes( (MGeomCam*)(camgeom.UncheckedAt(ict)),
    4504                             phot_per_pix,
    45054525                            Trigger_CT[ict],
    45064526                            Fadc_CT[ict],
     
    45084528                            pheinpix,
    45094529                            &(ntotphot[ict]),
    4510                             ict);
     4530                            ict,
     4531                            lambda,
     4532                            sigma_lambda,
     4533                            phot_per_pix,
     4534                            sigma_time,
     4535                            selected_pixel
     4536                            );
    45114537
    45124538      // NSB simulation
     
    45184544          for (int ict = 0; ict < ct_Number; ict++)
    45194545            {
    4520               for (UInt_t ui = 0;
    4521                   ui < ((MGeomCam*)(camgeom.UncheckedAt(ict)))->GetNumPixels();
    4522                   ui++)
     4546              for (UInt_t ui = first_pixel[ict]; ui <= last_pixel[ict]; ui++)
    45234547                {
    45244548                  nphe_from_nsb[ict] += nsb_phepns[ict][ui];
     
    45934617          // Fill the FADC information
    45944618          //
    4595           for(UInt_t ui=0;
    4596               ui<((MGeomCam*)(camgeom.UncheckedAt(ict)))->GetNumPixels();
    4597               ui++)
     4619          for(UInt_t ui = first_pixel[ict]; ui <= last_pixel[ict]; ui++)
    45984620            {
    45994621              for (int jslice = 0; jslice < FADC_slices_written; jslice++)
     
    46284650//------------------------------------------------------------
    46294651
    4630 int produce_calib_phes( MGeomCam *camgeom,      // The camera layout
    4631                         float     phot_per_pix, // Average number of photons per inner pixel
     4652int produce_calib_phes( MGeomCam *camgeom,       // The camera layout
    46324653                        MTrigger *trigger,
    46334654                        MFadc    *fadc,
    4634                         int      *itotnphe,     // total number of produced photoelectrons             
    4635                         float    *nphe,         // number of photoelectrons in each pixel
    4636                         int      *nphot,        // total number of photons in all pixels
    4637                         int       ict           // Telescope that is being analised to get the right QE.
     4655                        int      *itotnphe,      // total number of produced photoelectrons             
     4656                        float    *nphe,          // number of photoelectrons in each pixel
     4657                        int      *nphot,         // total number of photons in all pixels
     4658                        int       ict,           // Telescope that is being analised to get the right QE.
     4659                        float     lambda,        // Mean wavelength of light in nm
     4660                        float     sigma_lambda,  // Sigma of wavelengtgaussian spread
     4661                        float     phot_per_pix,  // Average # of photons per inner pixel
     4662                        float     sigma_time,    // Sigma of time spread of photons
     4663                        int       selected_pixel // if >= 0, only this pixel is used!
    46384664                        )
    46394665{
     
    46434669  float **qept;
    46444670  float radius_mm, focal_dist_mm;
     4671  int total_photons;
    46454672
    46464673  // reset variables
     
    46714698
    46724699  // Calculate total number of photons to be produced.
    4673   int total_photons = (int) (phot_per_pix * 3.14159265 * radius_mm * radius_mm /
    4674                              (*camgeom)[0].GetA());
     4700  if (selected_pixel < 0)
     4701    total_photons = (int) (phot_per_pix * 3.14159265 * radius_mm * radius_mm /
     4702                           (*camgeom)[0].GetA());
     4703  else
     4704    total_photons = (int) (phot_per_pix *
     4705                           (*camgeom)[selected_pixel].GetA() / (*camgeom)[0].GetA());
    46754706
    46764707  // loop over the photons
     
    46794710    {
    46804711
    4681       time = 0.;
    4682 
    4683       // Obtain photon coordinates on the camera. We assume a point source of light placed
    4684       // in the center of the mirror dish.
    4685 
    4686       // polar angle
    4687       float psi = RandomNumber * 2 * 3.14159265;
    4688       // angle between the telescope axis and the photon trajectory.
    4689       float epsilon = acos(1.-RandomNumber*(1.-cos_epsilon_max));
    4690       float tanepsilon = tan(epsilon);
    4691 
    4692       cx = focal_dist_mm*tanepsilon*cos(psi); // mm
    4693       cy = focal_dist_mm*tanepsilon*sin(psi); // mm
    4694 
    4695       // Angle between photon trajectory and camera plane:
    4696       phi = 3.14159265/2.-epsilon; // rad
     4712      // time
     4713      time = random.Gaus(4.*sigma_time, sigma_time);
     4714
     4715      cout << "### " << time << endl << endl;
    46974716
    46984717      // wavelength
    4699          
    4700       wl = 500.; // nm
    4701 
    4702 
    4703       if( (wl > WAVEBANDBOUND6) || (wl < WAVEBANDBOUND1) ||
    4704           (sqrt(cx*cx + cy*cy) > radius_mm ) )
     4718      wl = lambda;
     4719
     4720      if( (wl > WAVEBANDBOUND6) || (wl < WAVEBANDBOUND1))
    47054721        continue;
    47064722
    4707       //
    4708       // Pixelization
    4709       //
    4710       ipixnum = bpoint_is_in_pix(cx, cy, camgeom);
    4711 
    4712       // -1 = the photon is in none of the pixels
    4713       //  0 = the phton is in the central pixel, which is not used
    4714       if (ipixnum==-1 || ipixnum==0)
    4715         continue;
     4723      if (selected_pixel < 0)
     4724        {
     4725          // Obtain photon coordinates on the camera. We assume a point source of light placed
     4726          // in the center of the mirror dish.
     4727
     4728          // polar angle
     4729          float psi = RandomNumber * 2 * 3.14159265;
     4730          // angle between the telescope axis and the photon trajectory.
     4731          float epsilon = acos(1.-RandomNumber*(1.-cos_epsilon_max));
     4732          float tanepsilon = tan(epsilon);
     4733
     4734          cx = focal_dist_mm*tanepsilon*cos(psi); // mm
     4735          cy = focal_dist_mm*tanepsilon*sin(psi); // mm
     4736 
     4737          if (sqrt(cx*cx + cy*cy) > radius_mm )
     4738            continue;
     4739
     4740          // Angle between photon trajectory and camera plane:
     4741          phi = 3.14159265/2.-epsilon; // rad
     4742
     4743          //
     4744          // Pixelization
     4745          //
     4746          ipixnum = bpoint_is_in_pix(cx, cy, camgeom);
     4747
     4748          // -1 = the photon is in none of the pixels
     4749          //  0 = the phton is in the central pixel, which is not used
     4750          if (ipixnum==-1 || ipixnum==0)
     4751            continue;
     4752        }
     4753      else
     4754        {
     4755          // Angle between photon trajectory and camera plane:
     4756          phi = atan2( focal_dist_mm,
     4757                       sqrt( (*camgeom)[selected_pixel].GetX()*(*camgeom)[selected_pixel].GetX()+
     4758                             (*camgeom)[selected_pixel].GetY()*(*camgeom)[selected_pixel].GetY()));
     4759
     4760          ipixnum = selected_pixel;
     4761        }
     4762
    47164763
    47174764      // increase number of photons within pixels
     
    47934840      *itotnphe += 1;
    47944841    }
    4795 
     4842  cout << "$$" << endl;
    47964843  return(0);
    47974844
  • trunk/MagicSoft/Simulation/Detector/Camera/camera.h

    r5103 r5269  
    1919//=
    2020//= $RCSfile: camera.h,v $
    21 //= $Revision: 1.22 $
     21//= $Revision: 1.23 $
    2222//= $Author: moralejo $
    23 //= $Date: 2004-09-17 14:48:21 $
     23//= $Date: 2004-10-13 17:05:05 $
    2424//=
    2525//=//////////////////////////////////////////////////////////////////////
     
    7070#include "MParContainer.h"
    7171#include "MArray.h"
     72
    7273
    7374// command line options available
     
    341342                   float ro);
    342343
     344
     345int DoCalibration( class MFadc **Fadc_CT, class MTrigger **Trigger_CT,
     346                   class TObjArray camgeom,
     347                   float* nsb_trigresp, float *nsb_fadcresp,
     348                   class MLons *lons, class MLons *lons_outer,
     349                   float **diffnsb_phepns, int addElecNoise,
     350                   class TTree *EvtTree, class MRawEvtHeader **EvtHeader,
     351                   class MMcEvt **McEvt, class MRawEvtData **EvtData);
     352
     353
     354int produce_calib_phes( class MGeomCam *camgeom, class MTrigger *trigger,
     355                        class MFadc *fadc, int *itotnphe, float *nphe,
     356                        int *nphot, int ict, float lambda, float sigma_lambda,
     357                        float phot_per_pix, float sigma_time, int selected_pixel);
     358
     359
    343360//!@}
    344361
     
    350367/*
    351368 *$Log: not supported by cvs2svn $
     369 *Revision 1.22  2004/09/17 14:48:21  moralejo
     370 *
     371 *Changes to adapt headers to c++ style.
     372 *
    352373 *Revision 1.21  2004/09/16 15:24:53  moralejo
    353374 *Updated on CVS after long time...
  • trunk/MagicSoft/Simulation/Detector/Camera/creadparam.cxx

    r5245 r5269  
    1919//=
    2020//= $RCSfile: creadparam.cxx,v $
    21 //= $Revision: 1.30 $
     21//= $Revision: 1.31 $
    2222//= $Author: moralejo $
    23 //= $Date: 2004-10-12 13:32:02 $
     23//= $Date: 2004-10-13 17:05:05 $
    2424//=
    2525//=//////////////////////////////////////////////////////////////////////
     
    110110static float m_fraction[MAX_NUMBER_OF_CTS];
    111111
     112static int   CalibrationRun = 0;  // > 0 if a calibration run has been chosen
     113static float lambda = 0.;         // Mean wavelength for photons of calibration pulses.
     114static float sigma_lambda = 0.;   // Sigma of wavelength distribution for calibration.
     115static float phot_per_pix = 0.;   // Average number of photons per inner pixel for calibration.
     116static float sigma_time = 0.;     // Time spread (sigma of gaussian) of calibration photons.
     117static int   nevents = 0;         // Number of events in calibration run.
     118static int   selected_pixel = -1; // Selected pixel: if >= 0 ==> only this pixel is filled!
     119
     120
    112121// Coordinates of CT locations, in centimeters, in the Corsika system.
    113122
     
    599608    case mirror_fraction:
    600609
    601         sscanf(line, "%s %d %f", token, &j, &aux);
    602         m_fraction[j] = aux;
     610      sscanf(line, "%s %d %f", token, &j, &aux);
     611      m_fraction[j] = aux;
    603612       
    604         break;
     613      break;
     614
     615    case calibration_run:
     616
     617      sscanf(line, "%s %f %f %f %f %i %i", token, &lambda, &sigma_lambda, &phot_per_pix,
     618             &sigma_time, &nevents, &selected_pixel);
     619     
     620      CalibrationRun = 1;
     621     
     622      break;
    605623
    606624    case end_file:            //@< end of the parameters file
     
    13671385}
    13681386
     1387int is_calibration_run(){
     1388  return CalibrationRun;
     1389}
     1390
     1391void  get_calibration_properties(float *a, float *b, float *c, float *d, int *e, int *f)
     1392{
     1393  *a = lambda;
     1394  *b = sigma_lambda;
     1395  *c = phot_per_pix;
     1396  *d = sigma_time;
     1397  *e = nevents;
     1398  *f = selected_pixel;
     1399}
     1400
     1401
    13691402//=------------------------------------------------------------
    13701403//!@subsection Log of this file.
     
    13731406//
    13741407// $Log: not supported by cvs2svn $
     1408// Revision 1.30  2004/10/12 13:32:02  moralejo
     1409// *** empty log message ***
     1410//
    13751411// Revision 1.29  2004/09/17 14:48:21  moralejo
    13761412//
  • trunk/MagicSoft/Simulation/Detector/Camera/creadparam.h

    r5245 r5269  
    1919//=
    2020//= $RCSfile: creadparam.h,v $
    21 //= $Revision: 1.27 $
     21//= $Revision: 1.28 $
    2222//= $Author: moralejo $
    23 //= $Date: 2004-10-12 13:32:02 $
     23//= $Date: 2004-10-13 17:05:05 $
    2424//=
    2525//=//////////////////////////////////////////////////////////////////////
     
    110110T(sigma_x_cm_spot), /* Additional gaussian spread of mirror in x axis spot on camera */ \
    111111T(sigma_y_cm_spot), /* Additional gaussian spread of mirror in y axis spot on camera */ \
    112 T(misspoint_deg), /* Additional misspointing of Telescope direction*/ \
    113 T(trigger_delay), /*  Delay in ns between beginning of FADC
    114                       time window and the trigger instant.*/ \
     112T(misspoint_deg),   /* Additional misspointing of Telescope direction*/ \
     113T(trigger_delay),   /*  Delay in ns between beginning of FADC
     114                        time window and the trigger instant.*/ \
    115115T(telescope_location_cm), /* Telescope coordinates in Corsika system */ \
    116116T(mirror_fraction), /* Fraction of dish mirror really operative */ \
     117T(calibration_run), /* option to produce a calibration file */ \
    117118T(end_file)         /* end of the parameters file */
    118119
     
    190191float get_telescope_location_cm(int j, int icoor);
    191192float get_mirror_fraction(int j);
     193
     194int   is_calibration_run();
     195void  get_calibration_properties(float *lambda, float *sigma_lambda, float *phot_per_pix,
     196                                 float *sigma_time, int *nevents, int *selected_pixel);
    192197//!@}
    193198
     
    205210/*
    206211 * $Log: not supported by cvs2svn $
     212 * Revision 1.27  2004/10/12 13:32:02  moralejo
     213 * *** empty log message ***
     214 *
    207215 * Revision 1.26  2004/09/17 14:48:21  moralejo
    208216 *
  • trunk/MagicSoft/Simulation/Detector/Camera/input.card

    r5255 r5269  
    55ct_geom 1
    66# Quantum efficiency file:
    7 qe_file 0  /home/magic/MagicProgs/Simulation/Detector/Data/qe-emi-coat.RFL.dat
     7qe_file 0  /home/magic/CAMERA_NEW/MagicSoft/Simulation/Detector/Data/qe-emi-coat.RFL.dat
    88# Input file (one per telescope):
    9 input_file 0 /data1/magic/reflex/Gamma_zbin0_0_7_1000to1009_w0.rfl
     9# input_file 0 /data1/magic/reflex/Gamma_zbin0_0_7_1000to1009_w0.rfl
     10# Perform calibration run: lambda sigma_lambda phot_per_pixel time_sigma n_events [selected_pixel]
     11calibration_run 400. 30. 100. 5. 100 90
    1012# Ascii output file name:
    11 data_file ./Gamma_zbin0_0_7_1000to1009_w0.dat
     13#data_file ./Gamma_zbin0_0_7_1000to1009_w0.dat
     14data_file ./prueba.dat
    1215# root output file name:
    13 root_file ./Gamma_zbin0_0_7_1000to1009_w0.root
     16#root_file ./Gamma_zbin0_0_7_1000to1009_w0.root
     17root_file ./prueba.root
    1418# Trigger characteristics: gate length (ns), min. overlapping time (ns),
    1519# amplitude and FWHM of (gaussian) single phe response for trigger:
     
    1822trigger_single 0 4 4 2
    1923# Switch on NSB:
    20 nsb_on
     24#nsb_on
     25nsb_off
    2126# Number of photons from the diffuse NSB (nphe / ns 0.1*0.1 deg^2 239 m^2) and
    2227# minimum number of phe from shower required to simulate NSB:
    2328nsb_mean 0.13 10
    2429# Starfield (see Starfieldadder program)
    25 # starfield_file /home/magic/MagicProgs/Simulation/Detector/Starfield/starfield.rfl
     30# starfield_file /home/magic/CAMERA_NEW/MagicSoft/Simulation/Detector/Starfield/starfield.rfl
    2631# Electronic noise in FADC (sigma in ADC counts): Inner pixels, outer pixels, digital noise:
    2732fadc_noise 1.48 2.1 0.
     
    3540seeds 66767 45069
    3641# Directory where NSB database can be found for inner and outer pixels:
    37 nsb_directory  /home/magic/MagicProgs/Simulation/Detector/StarLight/inner/
    38 nsb_dir_outer  /home/magic/MagicProgs/Simulation/Detector/StarLight/outer/
     42nsb_directory  /home/magic/CAMERA_NEW/MagicSoft/Simulation/Detector/StarLight/inner/
     43nsb_dir_outer  /home/magic/CAMERA_NEW/MagicSoft/Simulation/Detector/StarLight/outer/
    3944#
    4045# FADC properties: shape of single phe response (1 means realistic one, from
    4146# Pulpo setup), integral in FADC counts for 1 phe. (3rd argument is ignored
    4247# unless gaussian shape - 1st argument=0 - was chosen) :
    43 fadc_prop 1 7.8 5.0
     48#fadc_prop 1 7.8 5.0
    4449# Same as above for outer pixels:
    45 fadc_outer 1 3.2 5.0
     50#fadc_outer 1 3.2 5.0
    4651#
    4752# tentative values for future fast (2 GHz) FADC:
    4853#
    49 # fadc_prop  0 40. 3.
    50 # fadc_outer 0 15. 3.
     54fadc_prop  0 40. 3.
     55fadc_outer 0 15. 3.
    5156# FADC sampling frequency and number of FADC slices:
    52 # fadc_GHz 2. 100
     57fadc_GHz 2. 100
    5358#
    5459# Write to output trigger information:
Note: See TracChangeset for help on using the changeset viewer.