Changeset 2389


Ignore:
Timestamp:
10/17/03 20:38:31 (21 years ago)
Author:
blanch
Message:
Now the camera program will stop if a undefined Geometry is required.
The NSB is internally scaled for any camera geometry and qe.
The seeds in the input card are used to initilize the random numbers.
The Amplitud stored in the MMcFadcHeader is the amplitud of the sphe reponse.
The Pedestal rms is simualted in a artificail empty event.
File:
1 edited

Legend:

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

    r2362 r2389  
    2121//
    2222// $RCSfile: camera.cxx,v $
    23 // $Revision: 1.62 $
     23// $Revision: 1.63 $
    2424// $Author: blanch $
    25 // $Date: 2003-09-26 11:25:07 $
     25// $Date: 2003-10-17 19:38:31 $
    2626//
    2727////////////////////////////////////////////////////////////////////////
     
    207207static float FADC_resp_fwhm_out = MFADC_RESPONSE_FWHM;
    208208static float FADC_noise = 2.0;
     209static float DIGITAL_noise = 2.0;
     210static float FADC_high2low = HIGH2LOWGAIN;
    209211
    210212//@: Trigger conditions for a single trigger mode
     
    358360  float l2, m2, n2;           //@< auxiliary variables
    359361  float num, den;      //@< auxiliary variables
     362  float factorqe_NSB[100];          //@< factor on the NSB depending of QE
    360363
    361364  int nshow=0;                //@< partial number of shower in a given run
     
    390393  Float_t fadc_elecnoise[CAMERA_PIXELS];  //@< Electronic niose for each pixel
    391394  Float_t fadc_pedestals[CAMERA_PIXELS];  //@< array for fadc pedestals values
     395  Float_t fadc_sigma[CAMERA_PIXELS];      //@< array for fadc pedestals sigma
     396  Float_t fadc_sigma_low[CAMERA_PIXELS];      //@< array for fadc pedestals sigma
    392397
    393398  float ext[iNUMWAVEBANDS] = { //@< average atmospheric extinction in each waveband
     
    567572      TriggerPixels[i]=TRIGGER_PIXELS_9;
    568573      break;
    569     default: camgeom[i]=new MGeomCamMagic;
    570       TriggerPixels[i]=TRIGGER_PIXELS_1;
     574    default:
     575      error( SIGNATURE, "Camera geometry %i is not defined. Stoping camera program ...", GeometryCamera[i]);
     576      exit(1);
    571577      break;
    572578    }
     
    590596    read_QE(qe_filename,ict);
    591597  }
     598
    592599  read_WC();
    593600
     
    614621  get_FADC_properties( &FADC_response_ampl, &FADC_response_fwhm,
    615622                       &FADC_resp_ampl_out, &FADC_resp_fwhm_out);
     623  FADC_high2low=get_High_to_Low();
    616624
    617625  // FIXME --- tirgger properties may depend on the Camrea geometry
     
    658666  // get different parameters of the simulation
    659667
    660   addElecNoise = add_elec_noise(&FADC_noise, &Trigger_noise);
     668  addElecNoise = add_elec_noise(&FADC_noise, &DIGITAL_noise, &Trigger_noise);
    661669  simulateNSB = get_nsb( &meanNSB, &nphe2NSB ); 
     670
    662671
    663672  // get selections on the parameters
     
    677686    strcpy( qe_filename, get_qe_filename(ict));
    678687
     688    // Look to factor for NSB respect to emi_coat PMTs
     689    if(!strcmp(qe_filename,"../Data/qe-emi-coat.RFL.dat"))
     690      factorqe_NSB[ict]=EMICOAT_NSB;
     691    else if(!strcmp(qe_filename,"../Data/qe-emi.RFL.dat"))
     692      factorqe_NSB[ict]=EMI_NSB;
     693    else if(!strcmp(qe_filename, "../Data/qe-intevac_hpd.RFL.dat"))
     694      factorqe_NSB[ict]=HPD_NSB;
     695    else{
     696      log(SIGNATURE,"WARNING : the factor for the diffuse NSB for this QE file (%s) is not known. The number of phe(ns stated in the inputcard will be used.\n",qe_filename);
     697      factorqe_NSB[ict]=1.0;
     698    }
    679699    log(SIGNATURE,
    680700        "%s:\n\t%20s:\t%s\n\t%20s:\t%s\n\t%20s\n\t%20s:\t%s\n\t%20s:\t%s\n\t%20s:\t%s\n\t%20s:\t%s\n\t%20s:\t%s\n",
     
    689709        );
    690710   
     711  // log parameters information
     712 
     713  log(SIGNATURE,
     714      "%s:\n\t%20s: %f: %s\n\t%20s: %f\n\t%20s: %f\n",
     715      "Parameters",
     716      "NSB (phes/ ns 0.1*0.1 deg^2 239 m^2)", meanNSB*factorqe_NSB[ict], ONoff(simulateNSB),
     717      "Pedestals = ", get_FADC_pedestal(),
     718      "High to Low gain = ", FADC_high2low
     719      );
     720 
    691721    // log Trigger information
    692722   
     
    741771      "Write_RawEvt",  ONoff(Write_RawEvt));
    742772     
    743   // log parameters information
    744  
    745   log(SIGNATURE,
    746       "%s:\n\t%20s: %f: %s\n\t%20s: %f\n",
    747       "Parameters",
    748       "NSB (phes/pixel)", meanNSB, ONoff(simulateNSB),
    749       "Pedestals = ", get_FADC_pedestal()
    750       );
    751  
    752773  // log selections
    753774 
     
    785806  }   
    786807
    787   // set all random numbers seeds
    788 
    789   setall( get_seeds(0), get_seeds(1) );
    790 
    791808  // get list of showers to evt. skip
    792809
     
    836853                    Trigger_response_ampl,
    837854                    Trigger_response_fwhm);  //@< A instance of the Class MTrigger
     855    Trigger_CT[i]->SetSeed(UInt_t(i+get_seeds(0)));
    838856  }
    839857
     
    849867  // is active: secureDiskThres*10000+riseDiskThres
    850868
    851   if(riseDiskThres>0.0)
    852     qThreshold[0][0]=((UInt_t)secureDiskThres*100)*100+riseDiskThres;
    853   else
    854     qThreshold[0][0]=0.0;
    855  
     869  for (int ict=0; ict<ct_Number;ict++){
     870    if(riseDiskThres>0.0)
     871      qThreshold[ict][0]=((UInt_t)secureDiskThres*100)*100+riseDiskThres;
     872    else
     873      qThreshold[ict][0]=0.0;
     874  }
    856875  //  Initialise McTrig information class if we want to save trigger informtion
    857876
     
    920939
    921940    Fadc_CT[ict]->SetPedestals(input_pedestals);
     941    Fadc_CT[ict]->SetHigh2LowGain(FADC_high2low);
    922942   
    923943    // Generate databse for the Fadc electronic noise
    924     if (addElecNoise)       
     944    if (addElecNoise){       
    925945      Fadc_CT[ict]->SetElecNoise(FADC_noise);
    926   }
     946      Fadc_CT[ict]->SetDigitalNoise(DIGITAL_noise);
     947    }
     948  }
     949
    927950  // Prepare the raw data output
    928951
     
    9971020                      &HeaderTrig[0]);
    9981021  }
    999   if (ct_Number==1)
     1022  if (ct_Number==1){
    10001023    HeaderTree.Branch("MGeomCam",GeometryName[0],
    10011024                      &camdummy[0]);
     1025    HeaderTree.Branch("MMcConfigRunHeader","MMcConfigRunHeader",
     1026                      &McConfigRunHeader[0]);
     1027  }
    10021028  else{
    10031029    char branchname[20];
     
    10101036                        &camdummy[ict]);
    10111037    }
     1038    for(int i=0;i<numberBranches;i++){
     1039      sprintf(help,"%i",i+1);
     1040      strcpy (branchname, "MMcConfigRunHeader;");
     1041      strcat (branchname, & help[0]);
     1042      strcat (branchname, ".");
     1043      HeaderTree.Branch(branchname,"MMcConfigRunHeader",
     1044                        &McConfigRunHeader[i]);
     1045    }
     1046   
    10121047  }
    10131048
     
    11131148
    11141149    HeaderFadc[0]->SetShape(0.0);
    1115     HeaderFadc[0]->SetAmplitud(FADC_response_ampl);
    1116     HeaderFadc[0]->SetFwhm(FADC_response_fwhm);
     1150    HeaderFadc[0]->SetAmplitud(FADC_response_ampl/
     1151                               sqrt(2*M_PI*FADC_response_fwhm
     1152                                    *FADC_response_fwhm),
     1153                               FADC_resp_ampl_out/
     1154                               sqrt(2*M_PI*FADC_resp_fwhm_out
     1155                                    *FADC_resp_fwhm_out));
     1156    HeaderFadc[0]->SetFwhm(FADC_response_fwhm,FADC_resp_fwhm_out);
     1157    HeaderFadc[0]->SetLow2High(FADC_high2low);
    11171158    HeaderFadc[0]->SetPedestal(&fadc_pedestals[0],
    11181159                               ((MGeomCam*)(camgeom.UncheckedAt(0)))->GetNumPixels());
     
    11221163  if(!Trigger_Loop && Write_McFADC && ct_Number>1){
    11231164    for(int i=0;i<ct_Number;i++){
     1165      Fadc_CT[i]->GetPedestals(&fadc_pedestals[0]);
    11241166      HeaderFadc[i]->SetShape(0.0);
    1125       HeaderFadc[i]->SetAmplitud(FADC_response_ampl);
    1126       HeaderFadc[i]->SetFwhm(FADC_response_fwhm);
     1167      HeaderFadc[i]->SetAmplitud(FADC_response_ampl/
     1168                                 sqrt(2*M_PI*FADC_response_fwhm
     1169                                      *FADC_response_fwhm),
     1170                                 FADC_resp_ampl_out/
     1171                                 sqrt(2*M_PI*FADC_resp_fwhm_out
     1172                                      *FADC_resp_fwhm_out));
     1173      HeaderFadc[i]->SetFwhm(FADC_response_fwhm,FADC_resp_fwhm_out);
     1174      HeaderFadc[i]->SetLow2High(FADC_high2low);
    11271175      HeaderFadc[i]->SetPedestal(&fadc_pedestals[0],((MGeomCam*)(camgeom.UncheckedAt(i)))->GetNumPixels());
    11281176      HeaderFadc[i]->SetElecNoise(&fadc_elecnoise[0],((MGeomCam*)(camgeom.UncheckedAt(i)))->GetNumPixels());
     
    11341182      for (imulticount=0;imulticount<=Trigger_loop_umult-Trigger_loop_lmult;imulticount++){
    11351183        for(itopocount=0;itopocount<=Trigger_loop_utop-Trigger_loop_ltop;itopocount++){
     1184          Fadc_CT[0]->GetPedestals(&fadc_pedestals[0]);
    11361185          HeaderFadc[iconcount]->SetShape(0.0);
    1137           HeaderFadc[iconcount]->SetAmplitud(Trigger_response_ampl);
    1138           HeaderFadc[iconcount]->SetFwhm(Trigger_response_fwhm);
     1186          HeaderFadc[iconcount]->SetAmplitud(FADC_response_ampl/
     1187                                             sqrt(2*M_PI*FADC_response_fwhm
     1188                                                  *FADC_response_fwhm),
     1189                                             FADC_resp_ampl_out/
     1190                                             sqrt(2*M_PI*FADC_resp_fwhm_out
     1191                                                  *FADC_resp_fwhm_out));
     1192          HeaderFadc[iconcount]->SetFwhm(FADC_response_fwhm,
     1193                                         FADC_resp_fwhm_out);
     1194          HeaderFadc[iconcount]->SetLow2High(FADC_high2low);
    11391195          HeaderFadc[iconcount]->SetPedestal(&fadc_pedestals[0], ct_NPixels);
    11401196          HeaderFadc[iconcount]->SetElecNoise(&fadc_elecnoise[0], ct_NPixels);
     
    11451201  }
    11461202
     1203  // UnSet flag in pixel 0 (not used for trigger) that indicates if secure pixel
     1204  // is active once it has been stored
     1205
     1206  for (int ict=0; ict<ct_Number;ict++){
     1207      qThreshold[ict][0]=999999.99;
     1208  }
     1209
    11471210
    11481211  //      create a Tree for the Event data stream
     
    11571220  if(!Trigger_Loop && ct_Number==1){
    11581221   
    1159     HeaderTree.Branch("MMcConfigRunHeader","MMcConfigRunHeader",
    1160                       &McConfigRunHeader[0]);
    1161 
    11621222    if (Write_RawEvt){
    11631223      EvtTree.Branch("MRawEvtHeader","MRawEvtHeader",
     
    11731233  else{
    11741234
    1175     if(ct_Number>1)
    1176       for(char branchname[10],i=0;i<numberBranches;i++){
    1177      
    1178         sprintf(help,"%i",i+1);
    1179         strcpy (branchname, "MMcConfigRunHeader;");
    1180         strcat (branchname, & help[0]);
    1181         strcat (branchname, ".");
    1182         HeaderTree.Branch(branchname,"MMcConfigRunHeader",
    1183                           &McConfigRunHeader[i]);
    1184       }
    1185    
    11861235    if (Write_McTrig){
    11871236      for(char branchname[10],i=0;i<numberBranches;i++){
     
    13031352        const Float_t size=
    13041353          (*((MGeomCam*)(camgeom.UncheckedAt(ict))))[ui].GetD();
    1305         diffnsb_phepns[ict][ui] = (Int_t(meanNSB*factorNSB_ct*100*size*size+0.5))/(100.0*size*size) * size*size;
     1354        diffnsb_phepns[ict][ui] = (Int_t(meanNSB*factorNSB_ct*100*size*size+0.5))/(100.0*size*size) * size*size*factorqe_NSB[ict];
    13061355      }
    13071356    }
     
    13211370      }
    13221371    }
     1372  }
     1373
     1374
     1375  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     1376  //
     1377  //  Now a empty event with the conditin in which the camera is run
     1378  //  is simulated. IN this way one gets an estimation of the
     1379  //  sigma for the pedestal of each FADC channel.
     1380  //  This sigma computtaion is done assuming any noise taht effects
     1381  //  the FADC but there is no rotation of the Star Field (otherwise it
     1382  //  should be done for each event)
     1383  //
     1384  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     1385
     1386  for(int ict=0;ict<ct_Number;ict++){
     1387    Fadc_CT[ict]->Reset() ;
     1388    if (addElecNoise){ 
     1389      Fadc_CT[ict]->ElecNoise(FADC_noise) ;
     1390    }
     1391    if(simulateNSB){
     1392      for(UInt_t ui=0;
     1393          ui<((MGeomCam*)(camgeom.UncheckedAt(ict)))->GetNumPixels();
     1394          ui++){
     1395        if(nsb_phepns[ict][ui]>0.0){
     1396          if((*((MGeomCam*)(camgeom.UncheckedAt(ict))))[ui].GetD()>(*((MGeomCam*)(camgeom.UncheckedAt(ict))))[0].GetD()){
     1397            k=lons_outer.GetResponse(nsb_phepns[ict][ui],0.01,
     1398                                     & nsb_trigresp[0],
     1399                                     & nsb_fadcresp[0]);
     1400          }
     1401          else{
     1402            k=lons.GetResponse(nsb_phepns[ict][ui],0.01,
     1403                               & nsb_trigresp[0],& nsb_fadcresp[0]);
     1404          }
     1405          if(k==0){
     1406            cout << "Exiting.\n";
     1407            exit(1);
     1408          }
     1409          Fadc_CT[ict]->AddSignal(ui,nsb_fadcresp);
     1410        }
     1411      }
     1412    }
     1413    Fadc_CT[ict]->Pedestals();
     1414    for(UInt_t ui=0;
     1415        ui<((MGeomCam*)(camgeom.UncheckedAt(ict)))->GetNumPixels();
     1416        ui++){
     1417      fadc_sigma[ui]=Fadc_CT[ict]->GetPedestalNoise(ui,1);
     1418      fadc_sigma_low[ui]=Fadc_CT[ict]->GetPedestalNoise(ui,0);
     1419    }
     1420    HeaderFadc[ict]->SetPedestalSigma(&fadc_sigma_low[0],&fadc_sigma[0],
     1421                                      ((MGeomCam*)(camgeom.UncheckedAt(ict)))
     1422                                      ->GetNumPixels());
    13231423  }
    13241424
     
    18731973                      //   fill pixel information
    18741974                      if (Lev1){
     1975                        if (addElecNoise) Fadc_CT[0]->DigitalNoise();
    18751976                        for(UInt_t i=0;
    18761977                            i<((MGeomCam*)(camgeom.UncheckedAt(0)))
     
    20472148         
    20482149            if ( Lev0MT[ict] > 0 || Write_All_Images) {
     2150
    20492151              Lev1MT[ict]= Trigger_CT[ict]->FirstLevel();
    20502152            }
     
    21102212             
    21112213                if (Lev1MT[ict]){
     2214                   if (addElecNoise) Fadc_CT[ict]->DigitalNoise();
    21122215                  for(UInt_t i=0;
    21132216                      i<((MGeomCam*)(camgeom.UncheckedAt(ict)))->GetNumPixels();
     
    37363839  int k, ii; // counters
    37373840
    3738   MTrigger trigger(397,camgeom,Trigger_gate_length, Trigger_overlaping_time, Trigger_response_ampl, Trigger_response_fwhm);
    3739   MFadc flashadc;
     3841  MTrigger trigger(camgeom->GetNumPixels(),camgeom,Trigger_gate_length, Trigger_overlaping_time, Trigger_response_ampl, Trigger_response_fwhm);
     3842  MFadc flashadc(camgeom->GetNumPixels());
    37403843
    37413844  static float wl_nm[iNUMWAVEBANDS + 1] = { WAVEBANDBOUND1,
     
    39554058  TRandom random;             // Random numbers generator
    39564059
    3957   random.SetSeed ((UInt_t) (RandomNumber*1000));
     4060  random.SetSeed(get_seeds(1));
    39584061
    39594062  ii = *inphe; // avoid dereferencing
     
    40544157//
    40554158// $Log: not supported by cvs2svn $
     4159// Revision 1.62  2003/09/26 11:25:07  blanch
     4160// Modification to be able to read MGeomCam branch for any Geometry.
     4161//
    40564162// Revision 1.61  2003/09/25 17:09:20  blanch
    40574163// Bug on the number of phe from diffuse NSB fixed.
Note: See TracChangeset for help on using the changeset viewer.