Changeset 1706 for trunk/MagicSoft/Simulation
- Timestamp:
- 01/14/03 13:40:17 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
r1694 r1706 21 21 // 22 22 // $RCSfile: camera.cxx,v $ 23 // $Revision: 1.5 0$23 // $Revision: 1.51 $ 24 24 // $Author: blanch $ 25 // $Date: 2003-01- 07 16:33:31$25 // $Date: 2003-01-14 13:40:17 $ 26 26 // 27 27 //////////////////////////////////////////////////////////////////////// … … 443 443 int addElecNoise; //@< Will we add ElecNoise? 444 444 445 float riseDiskThres; 446 float secureDiskThres; 447 445 448 int simulateNSB; //@< Will we simulate NSB? 446 449 int nphe2NSB; //@< From how many phe will we simulate NSB? … … 472 475 473 476 int anaPixels; 474 477 478 int nstoredevents = 0; 479 int flagstoring = 0; 480 475 481 float fCorrection; //@< Factor to apply to pixel values (def. 1.) 476 482 … … 609 615 Individual_Thres_Pixel = get_indi_thres_pixel(); 610 616 617 get_secure_threhold(&riseDiskThres,&secureDiskThres); 618 611 619 get_FADC_properties( &FADC_response_ampl, &FADC_response_fwhm); 612 620 … … 811 819 Trigger.CheckThreshold(&qThreshold[0]); 812 820 821 // Set flag in pixel 0 (not used for trigger) that indicates if secure pixel 822 // is active: secureDiskThres*10000+riseDiskThres 823 824 if(riseDiskThres>0.0) 825 qThreshold[0]=((UInt_t)secureDiskThres*100)*100+riseDiskThres; 826 else 827 qThreshold[0]=0.0; 813 828 814 829 // Initialise McTrig information class if we want to save trigger informtion … … 963 978 964 979 RunHeader->SetMagicNumber(kMagicNumber); 965 RunHeader->SetFormatVersion( 3);980 RunHeader->SetFormatVersion(4); 966 981 RunHeader->SetSoftVersion((UShort_t) (VERSION*10)); 967 982 RunHeader->SetRunType(256); … … 1288 1303 if (reflector_file_version<6){ 1289 1304 fread( (char*)&mcevth, mcevth.mysize(), 1, inputfile ); 1290 thetashw = mcevth.get_theta();1291 phishw = mcevth.get_phi();1292 1305 } 1293 1306 else{ 1294 1307 fread( (char*)&mcevth_2, mcevth_2.mysize(), 1, inputfile ); 1295 thetashw = mcevth_2.get_theta();1296 phishw = mcevth_2.get_phi();1297 1308 } 1298 1309 … … 1341 1352 m1 = sin(thetashw)*sin(phishw); 1342 1353 n1 = cos(thetashw); 1343 1344 // read the deviation of the telescope with respect to the shower 1345 1346 if (reflector_file_version<6) 1354 1355 if (reflector_file_version<6){ 1356 1357 mcevth.get_core(&coreX, &coreY); 1358 1359 // read the deviation of the telescope with respect to the shower 1347 1360 mcevth.get_deviations ( &thetaCT, &phiCT ); 1348 else 1349 mcevth_2.get_deviations ( &thetaCT, &phiCT ); 1350 1351 if ( (thetaCT == 0.) && (phiCT == 0.) ) { 1361 1362 if ( (thetaCT == 0.) && (phiCT == 0.) ) { 1352 1363 1353 // CT was looking to the source (both lines are parallel) 1354 // therefore, we calculate the impact parameter as the distance 1355 // between the CT axis and the core position 1356 1357 if (reflector_file_version<6) 1358 mcevth.get_core(&coreX, &coreY); 1359 else 1360 mcevth_2.get_core(&coreX, &coreY); 1361 1362 impactD = dist_r_P( 0., 0., 0., l1, m1, n1, coreX, coreY, 0. ); 1364 // CT was looking to the source (both lines are parallel) 1365 // therefore, we calculate the impact parameter as the distance 1366 // between the CT axis and the core position 1367 1368 impactD = dist_r_P( 0., 0., 0., l1, m1, n1, coreX, coreY, 0. ); 1369 thetaCT += thetashw; 1370 phiCT += phishw; 1371 1372 } else { 1373 1374 // the shower comes off-axis 1375 1376 // obtain with this the final direction of the CT 1377 1378 thetaCT += thetashw; 1379 phiCT += phishw; 1380 1381 // calculate vector for telescope 1382 1383 l2 = sin(thetaCT)*cos(phiCT); 1384 m2 = sin(thetaCT)*sin(phiCT); 1385 n2 = cos(thetaCT); 1386 1387 num = (m1*n2*coreX - m2*n1*coreX + l2*n1*coreY - l1*n2*coreY); 1388 den = (SQR(l1*m2 - l2*m1) + 1389 SQR(m1*n2 - m2*n1) + 1390 SQR(n1*l2 - n2*l1)); 1391 den = sqrt(den); 1392 1393 impactD = fabs(num)/den; 1394 1395 } 1396 } 1397 else{ 1398 mcevth_2.get_core(&coreX, &coreY); 1399 thetaCT=mcevth_2.get_theta_CT(); 1400 phiCT=mcevth_2.get_phi_CT(); 1401 if ( (thetaCT == thetashw) && (phiCT == phishw) ) { 1363 1402 1364 } else { 1365 1366 // the shower comes off-axis 1367 1368 // obtain with this the final direction of the CT 1369 1370 thetaCT += thetashw; 1371 phiCT += phishw; 1372 1373 // calculate vector for telescope 1374 1375 l2 = sin(thetaCT)*cos(phiCT); 1376 m2 = sin(thetaCT)*sin(phiCT); 1377 n2 = cos(thetaCT); 1378 1379 num = (m1*n2*coreX - m2*n1*coreX + l2*n1*coreY - l1*n2*coreY); 1380 den = (SQR(l1*m2 - l2*m1) + 1381 SQR(m1*n2 - m2*n1) + 1382 SQR(n1*l2 - n2*l1)); 1383 den = sqrt(den); 1384 1385 impactD = fabs(num)/den; 1386 1403 // CT was looking to the source (both lines are parallel) 1404 // therefore, we calculate the impact parameter as the distance 1405 // between the CT axis and the core position 1406 1407 impactD = dist_r_P( 0., 0., 0., l1, m1, n1, coreX, coreY, 0. ); 1408 1409 } else { 1410 1411 // the shower comes off-axis 1412 1413 // calculate vector for telescope 1414 1415 l2 = sin(thetaCT)*cos(phiCT); 1416 m2 = sin(thetaCT)*sin(phiCT); 1417 n2 = cos(thetaCT); 1418 1419 num = (m1*n2*coreX - m2*n1*coreX + l2*n1*coreY - l1*n2*coreY); 1420 den = (SQR(l1*m2 - l2*m1) + 1421 SQR(m1*n2 - m2*n1) + 1422 SQR(n1*l2 - n2*l1)); 1423 den = sqrt(den); 1424 1425 impactD = fabs(num)/den; 1426 1427 } 1387 1428 } 1388 1429 … … 1465 1506 rho); 1466 1507 1467 1468 1508 } 1469 1509 … … 1551 1591 // Set to zero the flag to know if some conditon has triggered 1552 1592 btrigger=0; 1593 flagstoring = 0; 1553 1594 // Loop over trigger threshold 1554 1595 int iconcount; 1555 1596 for (iconcount=0, ithrescount=0, fthrescount=Trigger_loop_lthres;fthrescount<=Trigger_loop_uthres;ithrescount++, fthrescount+=Trigger_loop_sthres){ 1556 for (i=0;i<CAMERA_PIXELS;i++) 1597 for (i=0;i<CAMERA_PIXELS;i++){ 1557 1598 fpixelthres[i]= 1558 1599 ((Float_t)(fthrescount)>=qThreshold[i])? 1559 1600 (Float_t)(fthrescount):qThreshold[i]; 1601 1602 // Rise the discrimnator threshold to avoid huge rates 1603 1604 if(riseDiskThres>0.0 && simulateNSB && nphe2NSB<=inumphe) 1605 for(int ii=0;ii<CAMERA_PIXELS;ii++) 1606 if( nsb_phepns_rotated[ii]>riseDiskThres) 1607 fpixelthres[ii]=secureDiskThres; 1608 } 1560 1609 Trigger.SetThreshold(fpixelthres); 1561 1610 … … 1665 1714 // 1666 1715 1716 if(!flagstoring) 1717 nstoredevents++; 1718 flagstoring = 1; 1719 1667 1720 if (Write_McEvt) { 1668 1721 Float_t ftime, ltime; … … 1681 1734 mcevth.get_coreY(), 1682 1735 impactD, 1683 mcevth_2.get_theta_CT(),1684 mcevth_2.get_phi_CT(),1736 phiCT, 1737 thetaCT, 1685 1738 ftime, 1686 1739 ltime, … … 1701 1754 else{ 1702 1755 Float_t Nmax, t0, tmax, a, b, c, chi2; 1703 mcevth .get_times(&ftime, <ime);1756 mcevth_2.get_times(&ftime, <ime); 1704 1757 chi2=mcevth_2.get_NKGfit(&Nmax, &t0, &tmax, &a, &b, &c); 1705 1758 McEvt->Fill( mcevth_2.get_evt_number(), … … 1715 1768 mcevth_2.get_coreY(), 1716 1769 impactD, 1770 mcevth_2.get_phi_CT(), 1717 1771 mcevth_2.get_theta_CT(), 1718 mcevth_2.get_phi_CT(),1719 1772 ftime, 1720 1773 ltime, … … 1761 1814 for (int i=0;i<CAMERA_PIXELS;i++) 1762 1815 fpixelthres[i]=qThreshold[i]; 1816 1817 // Rise the discrimnator threshold to avoid huge rates 1818 if(riseDiskThres>0.0 && simulateNSB && nphe2NSB<=inumphe) 1819 for(int ii=0;ii<CAMERA_PIXELS;ii++){ 1820 if( nsb_phepns_rotated[ii]>riseDiskThres) 1821 fpixelthres[ii]=secureDiskThres; 1822 } 1823 1763 1824 Trigger.SetThreshold(fpixelthres); 1764 1825 … … 1802 1863 // 1803 1864 fadc.TriggeredFadc(Trigger.GetFirstLevelTime(ii)); 1865 1866 nstoredevents++; 1804 1867 1805 1868 if (Write_McTrig){ … … 1851 1914 mcevth.get_coreY(), 1852 1915 impactD, 1853 mcevth_2.get_theta_CT(),1854 mcevth_2.get_phi_CT(),1916 phiCT, 1917 thetaCT, 1855 1918 ftime, 1856 1919 ltime, … … 1871 1934 else{ 1872 1935 Float_t Nmax, t0, tmax, a, b, c, chi2; 1873 mcevth .get_times(&ftime, <ime);1936 mcevth_2.get_times(&ftime, <ime); 1874 1937 chi2=mcevth_2.get_NKGfit(&Nmax, &t0, &tmax, &a, &b, &c); 1875 1938 McEvt->Fill( mcevth_2.get_evt_number(), … … 1885 1948 mcevth_2.get_coreY(), 1886 1949 impactD, 1950 mcevth_2.get_phi_CT(), 1887 1951 mcevth_2.get_theta_CT(), 1888 mcevth_2.get_phi_CT(),1889 1952 ftime, 1890 1953 ltime, … … 2022 2085 2023 2086 get_starfield_center(&sfRaH,&sfRaM,&sfRaS,&sfDeD,&sfDeM,&sfDeS); 2024 get_teles_axis(&telestheta,&telesphi); 2087 if (reflector_file_version<6){ 2088 get_teles_axis(&telestheta,&telesphi); 2089 mcevth.get_theta_range(&shthetamin, &shthetamax); 2090 mcevth.get_phi_range(&shphimin,&shphimax); 2091 mcevth.get_theta_range(&shthetamin, &shthetamax); 2092 mcevth.get_phi_range(&shphimin,&shphimax); 2093 corsika=UInt_t(mcevth.get_VersionPGM()*1000); 2094 for (int i=0; i< 10;i++) 2095 heights[i]=mcevth.get_HeightLev (i); 2096 rnum=mcevth.get_RunNumber(); 2097 } 2098 else{ 2099 telestheta=mcevth_2.get_theta_CT(); 2100 telesphi=mcevth_2.get_phi_CT(); 2101 mcevth_2.get_theta_range(&shthetamin, &shthetamax); 2102 mcevth_2.get_phi_range(&shphimin,&shphimax); 2103 corsika=UInt_t(mcevth_2.get_VersionPGM()*1000); 2104 for (int i=0; i< 10;i++) 2105 heights[i]=mcevth_2.get_HeightLev (i); 2106 rnum=mcevth_2.get_RunNumber(); 2107 } 2108 2025 2109 get_source_off(&sofftheta,&soffphi); 2026 mcevth.get_theta_range(&shthetamin, &shthetamax);2027 mcevth.get_phi_range(&shphimin,&shphimax);2028 corsika=UInt_t(mcevth.get_VersionPGM()*1000);2029 2110 if(!Trigger_Loop) icontrigger=0; 2030 2111 time (<ime); 2031 2112 ftime = ((Float_t)ltime)/1000; 2032 for (int i=0; i< 10;i++) 2033 heights[i]=mcevth.get_HeightLev (i); 2034 rnum=mcevth.get_RunNumber(); 2035 2036 McRunHeader->Fill(rnum, 2113 2114 if (reflector_file_version<6) 2115 McRunHeader->Fill(rnum, 2037 2116 (UInt_t) 0, 2038 2117 mcevth.get_DateRun(), … … 2047 2126 CAMERA_PIXELS, 2048 2127 (UInt_t)ntshow, 2049 (UInt_t)n trigger,2128 (UInt_t)nstoredevents, 2050 2129 0, 2051 2130 sfRaH, … … 2070 2149 heights, 2071 2150 corsika, 2072 (UInt_t)( REFL_VERSION_A*100),2151 (UInt_t)(reflector_file_version*100), 2073 2152 (UInt_t)(VERSION*100), 2074 2153 0); 2154 else 2155 McRunHeader->Fill(rnum, 2156 (UInt_t) 0, 2157 mcevth_2.get_DateRun(), 2158 ftime, 2159 icontrigger, 2160 !Write_All_Images, 2161 Write_McEvt, 2162 Write_McTrig, 2163 Write_McFADC, 2164 Write_RawEvt, 2165 addElecNoise, 2166 CAMERA_PIXELS, 2167 (UInt_t)ntshow, 2168 (UInt_t)nstoredevents, 2169 0, 2170 sfRaH, 2171 sfRaM, 2172 sfRaS, 2173 sfDeD, 2174 sfDeM, 2175 sfDeS, 2176 meanNSB, 2177 telestheta, 2178 telesphi, 2179 sofftheta, 2180 soffphi, 2181 shthetamax, 2182 shthetamin, 2183 shphimax, 2184 shphimin, 2185 mcevth_2.get_CWaveLower(), 2186 mcevth_2.get_CWaveUpper(), 2187 mcevth_2.get_slope(), 2188 1, 2189 heights, 2190 corsika, 2191 (UInt_t)(reflector_file_version*100), 2192 (UInt_t)(VERSION*100), 2193 0); 2194 // Fill some missing values for MRawRunHeader 2195 2196 RunHeader->SetRunNumber(rnum); 2197 RunHeader->SetNumEvents(nstoredevents); 2198 2075 2199 2076 2200 // Store qe for each PMT in output file … … 4028 4152 // 4029 4153 // $Log: not supported by cvs2svn $ 4154 // Revision 1.50 2003/01/07 16:33:31 blanch 4155 // Star Field Rotation has been implemented by Raul Orduna. Now there is a 4156 // rotation for each shower. It is done by a non enter pixel rotation assuming 4157 // a circular symetry of the camera. It is not exact but it is accurate enough and 4158 // much faster. 4159 // 4030 4160 // Revision 1.49 2002/12/13 10:04:07 blanch 4031 4161 // *** empty log message *** … … 4179 4309 // 4180 4310 // $Log: not supported by cvs2svn $ 4311 // Revision 1.50 2003/01/07 16:33:31 blanch 4312 // Star Field Rotation has been implemented by Raul Orduna. Now there is a 4313 // rotation for each shower. It is done by a non enter pixel rotation assuming 4314 // a circular symetry of the camera. It is not exact but it is accurate enough and 4315 // much faster. 4316 // 4181 4317 // Revision 1.49 2002/12/13 10:04:07 blanch 4182 4318 // *** empty log message ***
Note:
See TracChangeset
for help on using the changeset viewer.