Changeset 1517 for trunk/MagicSoft
- Timestamp:
- 09/09/02 17:00:49 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
r1512 r1517 21 21 // 22 22 // $RCSfile: camera.cxx,v $ 23 // $Revision: 1.4 1$23 // $Revision: 1.42 $ 24 24 // $Author: blanch $ 25 // $Date: 2002-09-0 4 09:57:42$25 // $Date: 2002-09-09 16:00:49 $ 26 26 // 27 27 //////////////////////////////////////////////////////////////////////// … … 304 304 //@: table of QE 305 305 static float *QElambda; 306 307 //@: table of lightguide = WC; 308 static float **WC; 309 310 //@: number of datapoints for the WC curve 311 static int pointsWC; 312 306 313 //!@} 307 314 … … 458 465 float zenfactor=1.0; // correction factor calculated from the extinction 459 466 460 float qTailCut; //@< Tail Cut value461 467 int anaPixels; 462 468 … … 499 505 MGeomCamMagic camgeom; // structure holding the camera definition 500 506 507 ct_NPixels=camgeom.GetNumPixels(); 508 read_QE(); 509 read_WC(); 501 510 502 511 //!@' @#### Definition of variables for |getopt()|. … … 618 627 // get different parameters of the simulation 619 628 620 qTailCut = get_tail_cut();621 629 addElecNoise = add_elec_noise(&FADC_noise, &Trigger_noise); 622 630 simulateNSB = get_nsb( &meanNSB, &nphe2NSB ); … … 699 707 700 708 log(SIGNATURE, 701 "%s:\n\t%20s: %f\n \t%20s: %f %s\n",709 "%s:\n\t%20s: %f\n", 702 710 "Parameters", 703 "t0 (Tail-cut)", qTailCut,704 711 "NSB (phes/pixel)", meanNSB, ONoff(simulateNSB)); 705 712 … … 768 775 769 776 anaPixels = get_ana_pixels(); 770 anaPixels = (anaPixels == -1) ? ct_NPixels : anaPixels; 777 anaPixels = (anaPixels == -1) ? camgeom.GetNumPixels() : anaPixels; 778 779 // Switched off writing TObject 780 781 MArray::Class()->IgnoreTObjectStreamer(); 782 MParContainer::Class()->IgnoreTObjectStreamer(); 771 783 772 784 // initialise ROOT … … 1180 1192 // allocate space for PMTs numbers of pixels 1181 1193 1182 fnpix = new float [ c t_NPixels];1194 fnpix = new float [ camgeom.GetNumPixels() ]; 1183 1195 1184 1196 … … 1490 1502 1491 1503 Lev0=1; 1504 Int_t NumImages = Lev1; 1492 1505 if(Lev1==0 && (Write_All_Images || btrigger)){ 1493 1506 btrigger= 1; 1494 Lev1=1;1507 NumImages=1; 1495 1508 Lev0=0; 1496 1509 } 1497 1510 1498 for (Int_t ii=0;ii< Lev1;ii++){1511 for (Int_t ii=0;ii<NumImages;ii++){ 1499 1512 if (Write_McTrig){ 1500 1513 McTrig[iconcount]->SetFirstLevel ((ii+1)*Lev0); … … 1516 1529 EvtHeader[iconcount]->FillHeader ( (UInt_t) (ntshow + nshow),0); 1517 1530 // fill pixel information 1518 for(int i=0;i<ct_NPixels;i++){ 1519 for (j=0;j<FADC_SLICES;j++){ 1520 fadcValues->AddAt(fadc.GetFadcSignal(i,j),j); 1531 if (Lev1){ 1532 for(UInt_t i=0;i<camgeom.GetNumPixels();i++){ 1533 for (j=0;j<FADC_SLICES;j++){ 1534 fadcValues->AddAt(fadc.GetFadcSignal(i,j),j); 1535 } 1536 EvtData[iconcount]->AddPixel(i,fadcValues,0); 1521 1537 } 1522 EvtData[iconcount]->AddPixel(i,fadcValues,0);1523 1538 } 1524 1539 } … … 1612 1627 ++ntrigger; 1613 1628 } 1629 Int_t NumImages = Lev1; 1614 1630 Lev0=1; 1615 1631 if (Lev1==0 && Write_All_Images){ 1616 Lev1=1;1632 NumImages=1; 1617 1633 Lev0=0; 1618 1634 } 1619 1635 1620 for(Int_t ii=0;ii< Lev1;ii++){1636 for(Int_t ii=0;ii<NumImages;ii++){ 1621 1637 // Loop over different level one triggers 1622 1638 … … 1645 1661 // fill pixel information 1646 1662 1647 for(int i=0;i<ct_NPixels;i++){ 1648 for (j=0;j<FADC_SLICES;j++){ 1649 fadcValues->AddAt(fadc.GetFadcSignal(i,j),j); 1663 if (Lev1){ 1664 for(UInt_t i=0;i<camgeom.GetNumPixels();i++){ 1665 for (j=0;j<FADC_SLICES;j++){ 1666 fadcValues->AddAt(fadc.GetFadcSignal(i,j),j); 1667 } 1668 EvtData[0]->AddPixel(i,fadcValues,0); 1650 1669 } 1651 EvtData[0]->AddPixel(i,fadcValues,0);1652 1670 } 1653 1671 } … … 1728 1746 } 1729 1747 1730 for (int i=0; i<c t_NPixels; ++i) {1748 for (int i=0; i<camgeom.GetNumPixels(); ++i) { 1731 1749 printf("%d (%d): ", i, npixneig[i]); 1732 1750 for (j=0; j<npixneig[i]; ++i) … … 2260 2278 2261 2279 //!----------------------------------------------------------- 2280 // @name read_QE 2281 // 2282 // @desc read QE data 2283 // 2284 // @date thu 5 17:59:57 CEST 2002 2285 //------------------------------------------------------------ 2286 // @function 2287 2288 //!@{ 2289 void 2290 read_QE(void){ 2291 ifstream qefile; 2292 char line[LINE_MAX_LENGTH]; 2293 int i, j, icount; 2294 float qe; 2295 2296 //------------------------------------------------------------ 2297 // second, pixels' QE 2298 2299 // try to open the file 2300 2301 log("read_QE", "Opening the file \"%s\" . . .\n", QE_FILE); 2302 2303 qefile.open( QE_FILE ); 2304 2305 // if it is wrong or does not exist, exit 2306 2307 if ( qefile.bad() ) 2308 error( "read_QE", "Cannot open \"%s\". Exiting.\n", QE_FILE ); 2309 2310 // read file 2311 2312 log("read_QE", "Reading data . . .\n"); 2313 2314 i=-1; 2315 icount = 0; 2316 2317 while ( ! qefile.eof() ) { 2318 2319 // get line from the file 2320 2321 qefile.getline(line, LINE_MAX_LENGTH); 2322 2323 // skip if comment 2324 2325 if ( *line == '#' ) 2326 continue; 2327 2328 // if it is the first valid value, it is the number of QE data points 2329 2330 if ( i < 0 ) { 2331 2332 // get the number of datapoints 2333 2334 sscanf(line, "%d", &pointsQE); 2335 2336 // allocate memory for the table of QEs 2337 2338 QE = new float ** [ct_NPixels]; 2339 2340 for ( i=0; i<ct_NPixels; ++i ) { 2341 QE[i] = new float * [2]; 2342 QE[i][0] = new float[pointsQE]; 2343 QE[i][1] = new float[pointsQE]; 2344 } 2345 2346 QElambda = new float [pointsQE]; 2347 2348 for ( i=0; i<pointsQE; ++i ) { 2349 qefile.getline(line, LINE_MAX_LENGTH); 2350 sscanf(line, "%f", &QElambda[i]); 2351 } 2352 2353 i=0; 2354 2355 continue; 2356 } 2357 2358 // get the values (num-pixel, num-datapoint, QE-value) 2359 2360 if( sscanf(line, "%d %d %f", &i, &j, &qe) != 3 ) 2361 break; 2362 2363 if ( ((i-1) < ct_NPixels) && ((i-1) > -1) && 2364 ((j-1) < pointsQE) && ((j-1) > -1) ) { 2365 QE[i-1][0][j-1] = QElambda[j-1]; 2366 QE[i-1][1][j-1] = qe; 2367 } 2368 2369 if ( i > ct_NPixels) break; 2370 2371 icount++; 2372 2373 } 2374 2375 if(icount/pointsQE < ct_NPixels){ 2376 error( "read_QE", "The quantum efficiency file is faulty\n (found only %d pixels instead of %d).\n", 2377 icount/pointsQE, ct_NPixels ); 2378 } 2379 2380 // close file 2381 2382 qefile.close(); 2383 2384 // test QE 2385 2386 for(icount=0; icount< ct_NPixels; icount++){ 2387 for(i=0; i<pointsQE; i++){ 2388 if( QE[icount][0][i] < 100. || QE[icount][0][i] > 1000. || 2389 QE[icount][1][i] < 0. || QE[icount][1][i] > 100.){ 2390 error( "read_QE", "The quantum efficiency file is faulty\n pixel %d, point %d is % f, %f\n", 2391 icount, i, QE[icount][0][i], QE[icount][1][i] ); 2392 } 2393 } 2394 } 2395 2396 // end 2397 2398 log("read_QE", "Done.\n"); 2399 } 2400 //!@} 2401 2402 //!----------------------------------------------------------- 2403 // @name read_WC 2404 // 2405 // @desc read WC data 2406 // 2407 // @date thu 5 17:59:57 CEST 2002 2408 //------------------------------------------------------------ 2409 // @function 2410 2411 //!@{ 2412 void 2413 read_WC(void){ 2414 ifstream wcfile; 2415 char line[LINE_MAX_LENGTH]; 2416 int i; 2417 2418 //------------------------------------------------------------ 2419 // Read Light Guides data 2420 2421 // try to open the file 2422 2423 log("read_QE", "Opening the file \"%s\" . . .\n", WC_FILE); 2424 2425 wcfile.open( WC_FILE ); 2426 2427 // if it is wrong or does not exist, exit 2428 2429 if ( wcfile.bad() ) 2430 error( "read_WC", "Cannot open \"%s\". Exiting.\n", QE_FILE ); 2431 2432 // read file 2433 2434 log("read_WC", "Reading data . . .\n"); 2435 2436 // get line from the file 2437 2438 wcfile.getline(line, LINE_MAX_LENGTH); 2439 2440 // get the number of datapoints 2441 2442 sscanf(line, "%d", &pointsWC); 2443 2444 // allocate memory for the table of QEs 2445 2446 WC = new float * [2]; 2447 WC[0] = new float[pointsWC]; 2448 WC[1] = new float[pointsWC]; 2449 2450 for ( i=0; i<pointsWC; ++i ) { 2451 wcfile.getline(line, LINE_MAX_LENGTH); 2452 sscanf(line, "%f %f", &WC[0][i], &WC[1][i]); 2453 } 2454 2455 // close file 2456 2457 wcfile.close(); 2458 2459 // read 2460 2461 log("read_WC", "Done.\n"); 2462 } 2463 //!@} 2464 2465 //!----------------------------------------------------------- 2262 2466 // @name read_pixels 2263 2467 // … … 2900 3104 static int k, ipixnum; 2901 3105 static float cx, cy, wl, qe, t; 3106 static float cu, cv, cw; 2902 3107 static MCCphoton photon; 2903 3108 static float **qept; … … 2944 3149 fread( ((char*)&photon)+SIZE_OF_FLAGS, photon.mysize()-SIZE_OF_FLAGS, 1, sp ); 2945 3150 3151 2946 3152 // increase number of photons 2947 3153 … … 3050 3256 qe = lin_interpol(qept[0][k-1], qept[1][k-1], qept[0][k], qept[1][k], wl) / 100.0; 3051 3257 3052 // if random > quantum efficiency, reject it 3258 // Apply incient angular correction due to Light Guides 3259 3260 cu=photon.get_u(); 3261 cv=photon.get_v(); 3262 cw=90.0-acos(sqrt(1-cu*cu-cv*cv))*pi/180.0; 3263 cout<<" Hola "<<cu<<" "<<cv<<" "<<cw<<endl; 3264 3265 // find data point in the QE table (-> k) 3266 3267 k = 0; 3268 while (k < pointsWC-1 && WC[0][k] < cw){ 3269 k++; 3270 } 3271 3272 cout<<" Hola 2 "<<k<<endl; 3273 3274 // correct the qe with WC data. 3275 3276 cout<<" Hola 3 "<<qe<<" "; 3277 3278 qe = qe*lin_interpol(WC[0][k-1], WC[1][k-1], WC[0][k], WC[1][k], cw); 3279 3280 cout<<qe<<endl; 3281 // if random > quantum efficiency, reject it 3053 3282 3054 3283 if ( (RandomNumber) > qe ) { … … 3378 3607 // 3379 3608 // $Log: not supported by cvs2svn $ 3609 // Revision 1.41 2002/09/04 09:57:42 blanch 3610 // Modifications done to use MGeomCam from MARS. 3611 // 3380 3612 // Revision 1.40 2002/07/16 16:15:22 blanch 3381 3613 // A first implementation of the Star field rotation has been done. … … 3500 3732 // 3501 3733 // $Log: not supported by cvs2svn $ 3734 // Revision 1.41 2002/09/04 09:57:42 blanch 3735 // Modifications done to use MGeomCam from MARS. 3736 // 3502 3737 // Revision 1.40 2002/07/16 16:15:22 blanch 3503 3738 // A first implementation of the Star field rotation has been done.
Note:
See TracChangeset
for help on using the changeset viewer.