Changeset 1517


Ignore:
Timestamp:
09/09/02 17:00:49 (22 years ago)
Author:
blanch
Message:
Statement has been included to avoid writting to disk MParContainer and MArray.
It has also been added the effect of the WC, the actual values must be added,
once they are measured.
File:
1 edited

Legend:

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

    r1512 r1517  
    2121//
    2222// $RCSfile: camera.cxx,v $
    23 // $Revision: 1.41 $
     23// $Revision: 1.42 $
    2424// $Author: blanch $
    25 // $Date: 2002-09-04 09:57:42 $
     25// $Date: 2002-09-09 16:00:49 $
    2626//
    2727////////////////////////////////////////////////////////////////////////
     
    304304//@: table of QE
    305305static float *QElambda;
     306
     307//@: table of lightguide = WC;
     308static float **WC;
     309
     310//@: number of datapoints for the WC curve
     311static int pointsWC;
     312
    306313//!@}
    307314
     
    458465  float zenfactor=1.0;  //  correction factor calculated from the extinction
    459466
    460   float qTailCut;             //@< Tail Cut value
    461467  int anaPixels;
    462468   
     
    499505  MGeomCamMagic camgeom; // structure holding the camera definition
    500506
     507  ct_NPixels=camgeom.GetNumPixels();
     508  read_QE();
     509  read_WC();
    501510
    502511  //!@' @#### Definition of variables for |getopt()|.
     
    618627  // get different parameters of the simulation
    619628
    620   qTailCut = get_tail_cut();
    621629  addElecNoise = add_elec_noise(&FADC_noise, &Trigger_noise);
    622630  simulateNSB = get_nsb( &meanNSB, &nphe2NSB ); 
     
    699707 
    700708  log(SIGNATURE,
    701       "%s:\n\t%20s: %f\n\t%20s: %f %s\n",
     709      "%s:\n\t%20s: %f\n",
    702710      "Parameters",
    703       "t0 (Tail-cut)", qTailCut,
    704711      "NSB (phes/pixel)", meanNSB, ONoff(simulateNSB));
    705712 
     
    768775   
    769776  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();
    771783
    772784  // initialise ROOT
     
    11801192  // allocate space for PMTs numbers of pixels
    11811193 
    1182   fnpix = new float [ ct_NPixels ];
     1194  fnpix = new float [ camgeom.GetNumPixels() ];
    11831195
    11841196     
     
    14901502                 
    14911503                  Lev0=1;
     1504                  Int_t NumImages = Lev1;
    14921505                  if(Lev1==0 && (Write_All_Images || btrigger)){
    14931506                    btrigger= 1;
    1494                     Lev1=1;
     1507                    NumImages=1;
    14951508                    Lev0=0;
    14961509                  }
    14971510
    1498                   for (Int_t ii=0;ii<Lev1;ii++){
     1511                  for (Int_t ii=0;ii<NumImages;ii++){
    14991512                      if (Write_McTrig){
    15001513                          McTrig[iconcount]->SetFirstLevel ((ii+1)*Lev0);
     
    15161529                      EvtHeader[iconcount]->FillHeader ( (UInt_t) (ntshow + nshow),0);
    15171530                      //   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);
    15211537                        }
    1522                         EvtData[iconcount]->AddPixel(i,fadcValues,0);
    15231538                      }
    15241539                    }
     
    16121627            ++ntrigger;
    16131628          }
     1629          Int_t NumImages = Lev1;
    16141630          Lev0=1;
    16151631          if (Lev1==0 && Write_All_Images){
    1616             Lev1=1;
     1632            NumImages=1;
    16171633            Lev0=0;
    16181634          }
    16191635
    1620           for(Int_t ii=0;ii<Lev1;ii++){
     1636          for(Int_t ii=0;ii<NumImages;ii++){
    16211637            //  Loop over different level one triggers
    16221638
     
    16451661              //   fill pixel information
    16461662             
    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);
    16501669                }
    1651                 EvtData[0]->AddPixel(i,fadcValues,0);
    16521670              }
    16531671            }       
     
    17281746        }
    17291747       
    1730         for (int i=0; i<ct_NPixels; ++i) {
     1748        for (int i=0; i<camgeom.GetNumPixels(); ++i) {
    17311749          printf("%d (%d): ", i, npixneig[i]);
    17321750          for (j=0; j<npixneig[i]; ++i)
     
    22602278
    22612279//!-----------------------------------------------------------
     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//!@{
     2289void
     2290read_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//!@{
     2412void
     2413read_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//!-----------------------------------------------------------
    22622466// @name read_pixels 
    22632467//                         
     
    29003104  static int k, ipixnum;
    29013105  static float cx, cy, wl, qe, t;
     3106  static float cu, cv, cw;
    29023107  static MCCphoton photon;
    29033108  static float **qept;
     
    29443149    fread( ((char*)&photon)+SIZE_OF_FLAGS, photon.mysize()-SIZE_OF_FLAGS, 1, sp );
    29453150         
     3151
    29463152    // increase number of photons
    29473153         
     
    30503256    qe = lin_interpol(qept[0][k-1], qept[1][k-1], qept[0][k], qept[1][k], wl) / 100.0;
    30513257
    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
    30533282
    30543283    if ( (RandomNumber) > qe ) {
     
    33783607//
    33793608// $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//
    33803612// Revision 1.40  2002/07/16 16:15:22  blanch
    33813613// A first implementation of the Star field rotation has been done.
     
    35003732//
    35013733// $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//
    35023737// Revision 1.40  2002/07/16 16:15:22  blanch
    35033738// A first implementation of the Star field rotation has been done.
Note: See TracChangeset for help on using the changeset viewer.