Changeset 5269 for trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
- Timestamp:
- 10/13/04 18:05:05 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
r5268 r5269 21 21 // 22 22 // $RCSfile: camera.cxx,v $ 23 // $Revision: 1.7 3$23 // $Revision: 1.74 $ 24 24 // $Author: moralejo $ 25 // $Date: 2004-10-13 1 4:28:59$25 // $Date: 2004-10-13 17:05:05 $ 26 26 // 27 27 //////////////////////////////////////////////////////////////////////// … … 238 238 static float Spot_y=0.0; 239 239 static float Spotsigma=0.0; 240 241 static int CalibrationRun = 0;242 240 243 241 … … 717 715 // get filenames 718 716 719 CalibrationRun = 1; 720 if (! CalibrationRun) 717 if (! is_calibration_run()) 721 718 for(int ict=0;ict<ct_Number;ict++) 722 719 { … … 1682 1679 1683 1680 1684 if ( CalibrationRun)1681 if (is_calibration_run()) 1685 1682 { 1686 1683 DoCalibration(Fadc_CT, Trigger_CT, camgeom, nsb_trigresp, nsb_fadcresp, … … 4455 4452 { 4456 4453 4457 int ntshow = 0; 4454 int nevent = 0; 4455 int maxevents; 4458 4456 int lons_return; 4459 4457 … … 4464 4462 float timefirst = 0.; 4465 4463 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 4466 4488 4467 4489 TArrayC *fadcValues; //@< the analog Fadc High gain signal for pixels … … 4476 4498 float *pheinpix = new float [ct_NPixels]; 4477 4499 4478 for (int calevent = 0; calevent < 1; calevent++)4500 for (int calevent = 0; calevent < maxevents; calevent++) 4479 4501 { 4480 4502 // … … 4493 4515 } 4494 4516 4495 n tshow++;4496 4497 if((n tshow+1)%100 == 1)4498 log(SIGNATURE, "Event %d\n", n tshow);4517 nevent++; 4518 4519 if((nevent+1)%100 == 1) 4520 log(SIGNATURE, "Event %d\n", nevent); 4499 4521 4500 4522 // Produce the photoelectrons 4501 float phot_per_pix = 100.;4502 4523 for(int ict = 0; ict < ct_Number; ict++) 4503 4524 produce_calib_phes( (MGeomCam*)(camgeom.UncheckedAt(ict)), 4504 phot_per_pix,4505 4525 Trigger_CT[ict], 4506 4526 Fadc_CT[ict], … … 4508 4528 pheinpix, 4509 4529 &(ntotphot[ict]), 4510 ict); 4530 ict, 4531 lambda, 4532 sigma_lambda, 4533 phot_per_pix, 4534 sigma_time, 4535 selected_pixel 4536 ); 4511 4537 4512 4538 // NSB simulation … … 4518 4544 for (int ict = 0; ict < ct_Number; ict++) 4519 4545 { 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++) 4523 4547 { 4524 4548 nphe_from_nsb[ict] += nsb_phepns[ict][ui]; … … 4593 4617 // Fill the FADC information 4594 4618 // 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++) 4598 4620 { 4599 4621 for (int jslice = 0; jslice < FADC_slices_written; jslice++) … … 4628 4650 //------------------------------------------------------------ 4629 4651 4630 int produce_calib_phes( MGeomCam *camgeom, // The camera layout 4631 float phot_per_pix, // Average number of photons per inner pixel 4652 int produce_calib_phes( MGeomCam *camgeom, // The camera layout 4632 4653 MTrigger *trigger, 4633 4654 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! 4638 4664 ) 4639 4665 { … … 4643 4669 float **qept; 4644 4670 float radius_mm, focal_dist_mm; 4671 int total_photons; 4645 4672 4646 4673 // reset variables … … 4671 4698 4672 4699 // 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()); 4675 4706 4676 4707 // loop over the photons … … 4679 4710 { 4680 4711 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; 4697 4716 4698 4717 // 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)) 4705 4721 continue; 4706 4722 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 4716 4763 4717 4764 // increase number of photons within pixels … … 4793 4840 *itotnphe += 1; 4794 4841 } 4795 4842 cout << "$$" << endl; 4796 4843 return(0); 4797 4844
Note:
See TracChangeset
for help on using the changeset viewer.