Ignore:
Timestamp:
05/11/00 14:57:27 (24 years ago)
Author:
blanch
Message:
The option to loop over several trigger configurations has been included.
Some non-sense with triggertime range has been solved.
Montecarlo information and ADC counts are saved in a root file.
There was a problem with the maximum number of phe that the program could analyse. Now there is not limit.
File:
1 edited

Legend:

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

    r383 r388  
    2121//
    2222// $RCSfile: camera.cxx,v $
    23 // $Revision: 1.7 $
     23// $Revision: 1.8 $
    2424// $Author: blanch $
    25 // $Date: 2000-03-24 18:10:46 $
     25// $Date: 2000-05-11 13:57:27 $
    2626//
    2727////////////////////////////////////////////////////////////////////////
     
    217217//@: flag: TRUE: show all trigger singnal in the screen; FALSE: don't
    218218static int Trigger_Scan = FALSE;
     219
     220//@: flag: TRUE: loop trigger analysis over several thresholds, multiplicities and topologies; FALSE: a single trigger configuration
     221static int Trigger_Loop = FALSE;
     222
     223//@: Upper and lower edges of the trigger loop
     224static int Trigger_loop_lthres = 0;
     225static int Trigger_loop_uthres = 10;
     226static int Trigger_loop_lmult = 2;
     227static int Trigger_loop_umult = 10;
     228static int Trigger_loop_ltop = 0;
     229static int Trigger_loop_utop = 2;
    219230
    220231//!@}
     
    373384  MCCphoton cphoton;          //@< Cherenkov Photon class (MC)
    374385
    375   Photoelectron *photoe = NULL; //@< array of the photoelectrons of one event
    376386  int inumphe;                //@< number of photoelectrons in an event
    377387
     
    421431  int itrigger;               //@< index of pixel fired
    422432  int ntrigger = 0;           //@< number of triggers in the whole file
     433  int ithrescount;            //@< counter for loop over threshold trigger
     434  int imulticount;            //@< counter for loop over multiplicity trigger
     435  int itopocount;             //@< counter for loop over topology trigger
     436  float fpixelthres[TRIGGER_PIXELS];
     437
     438  float fadcValues[(Int_t) SLICES_MFADC];  //@< the analog Fadc siganl for pixels
    423439
    424440  float plateScale_cm2deg;    //@< plate scale (deg/cm)
     
    511527  FADC_Scan = get_FADC_Scan();
    512528  Trigger_Scan = get_Trigger_Scan();
     529  Trigger_Loop = get_Trigger_Loop(&Trigger_loop_lthres, &Trigger_loop_uthres, &Trigger_loop_lmult, &Trigger_loop_umult, &Trigger_loop_ltop, &Trigger_loop_utop);
     530
    513531
    514532  // get filenames
     
    581599      "Energy", ONoff(Select_Energy), Select_Energy_le, Select_Energy_ue);
    582600 
     601  //  Definition and initialization of array to save trigger statistics
     602 
     603  int ntriggerloop[(int) (Trigger_loop_uthres+1)][Trigger_loop_umult+1][Trigger_loop_utop+1];
     604
     605  for (ithrescount=Trigger_loop_lthres;ithrescount<=Trigger_loop_uthres;ithrescount++){
     606    for (imulticount=Trigger_loop_lmult;imulticount<=Trigger_loop_umult;imulticount++){
     607      for(itopocount=Trigger_loop_ltop;itopocount<=Trigger_loop_utop;itopocount++){
     608        ntriggerloop[ithrescount][imulticount][itopocount]=0;
     609      }
     610    }   
     611  }
     612
    583613  // set all random numbers seeds
    584614
     
    605635
    606636  read_pixels(&cam);
    607 
    608   // allocate memory for the photoelectrons
    609 
    610   photoe = new Photoelectron[iMAXNUMPHE];
    611637
    612638  Int_t Lev0, Lev1, Lev2 ;
     
    737763    k = produce_nsbrates( starfieldname,
    738764                          &cam,
    739                           photoe, // only a dummy here
    740765                          nsbrate_phepns );
    741766    if (k != 0){
     
    835860        //
    836861        Trigger.Reset() ;
     862        Trigger.ClearFirst();
     863        Trigger.ClearZero();
    837864        fadc.Reset() ;
    838865
     
    928955        }
    929956
    930         // read the photons and produce the photoelectrons
    931 
    932         k = produce_phes( inputfile,
    933                           &cam,
    934                           WAVEBANDBOUND1,
    935                           WAVEBANDBOUND6,
    936                           photoe,   // will be changed by the function!
    937                           &inumphe, // important for later: the size of photoe[]
    938                           fnpix,    // will be changed by the function!
    939                           &ncph,    // will be changed by the function!
    940                           &arrtmin_ns, // will be changed by the function!
    941                           &arrtmax_ns // will be changed by the function!
    942                           );
    943 
    944         if( k != 0 ){ // non-zero returnvalue means error
    945           cout << "Exiting.\n";
    946           exit(1);
    947         }
    948          
    949         log(SIGNATURE, "End of this event: %d cphs(+%d). . .\n",
    950             ncph, ntcph);
    951 
    952         ntcph += ncph;
    953 
    954         // skip it ?
    955        
    956         for ( i=0; i<nSkip; ++i ) {
    957           if (Skip[i] == (nshow+ntshow)) {
    958             i = -1;
    959             break;
    960           }
    961         }
    962        
    963         // if after the previous loop, the exit value of i is -1
    964         // then the shower number is in the list of showers to be
    965         // skipped
    966        
    967         if (i == -1) {
    968           log(SIGNATURE, "\t\tskipped!\n");
    969           continue;
    970         }
    971        
    972957        // energy cut
    973958       
     
    979964          }
    980965        }
     966
     967        // Read first and last time and put inumphe to 0
     968
     969        mcevth.get_times(&arrtmin_ns,&arrtmax_ns);
     970        inumphe=0;
    981971
    982972        // NSB simulation
     
    992982                                ext,
    993983                                fnpix,   // will be changed by the function!
    994                                 photoe,  // will be changed by the function!
     984                                &Trigger,  // will be changed by the function!
     985                                &fadc,      // will be changed by the function!
    995986                                &inumphe, // important for later: the size of photoe[]
    996987                                baseline_mv // will be generated by the function
     
    1001992            exit(1);
    1002993          }
    1003 
     994         
    1004995        }// end if(simulateNSB) ...
    1005996
    1006 
    1007 //      cout << arrtmin_ns << " " << arrtmax_ns << "\n";
    1008 //      for(i=0; i<cam.inumpixels; i++){
    1009 //        cout << i << " " << baseline_mv[i] <<"\n";
    1010 //      }
    1011 
    1012           cout << "Total number of phes: " << inumphe <<endl;
    1013          
    1014         // TRIGGER HERE
    1015 
    1016         //   
    1017         //   Put  values of the analog signal for
    1018         //   each pixel from photoe array
    1019         //
    1020        
    1021         for(i=0;i<inumphe;i++){
    1022           Trigger.FillShow(photoe[i].ipixnum,float((photoe[i].iarrtime_ns-arrtmin_ns)));
    1023           fadc.Fill( photoe[i].ipixnum,(photoe[i].iarrtime_ns-arrtmin_ns) , Trigger.FillShow(photoe[i].ipixnum,float((photoe[i].iarrtime_ns-arrtmin_ns))));
    1024 }
    1025 
    1026         //
    1027         //   now the noise of the electronic
    1028         //   (preamps, optical transmission,..)  is introduced.
    1029         //   This is done inside the class MTrigger by the method ElecNoise.
    1030         //   
    1031         Trigger.ElecNoise() ;
    1032         fadc.ElecNoise() ;
    1033        
    1034 
    1035         Trigger.Diskriminate() ;
    1036 
    1037         //
    1038         //   look if in all the signals in the trigger signal branch
    1039         //   is a possible Trigger. Therefore we habe to diskriminate all
    1040         //   the simulated analog signals (Method Diskriminate in class
    1041         //   MTrigger). We look simultanously for the moments at which
    1042         //   there are more than TRIGGER_MULTI pixels above the
    1043         //   CHANNEL_THRESHOLD.
    1044         //
    1045 
    1046         McTrig->SetZeroLevel( Lev0 = (Short_t) Trigger.ZeroLevel() ) ;
    1047 
    1048         Lev1 = Lev2 = 0 ;
    1049        
    1050         //
    1051         //   Start the First Level Trigger simulation
    1052         //
    1053 
    1054         if ( Lev0 > 0 ) {
    1055           McTrig->SetFirstLevel ( Lev1 = Trigger.FirstLevel() )  ;
     997        // read the photons and produce the photoelectrons
     998
     999        k = produce_phes( inputfile,
     1000                          &cam,
     1001                          WAVEBANDBOUND1,
     1002                          WAVEBANDBOUND6,
     1003                          &Trigger,   // will be changed by the function!
     1004                          &fadc,      // will be changed by the function!
     1005                          &inumphe, // important for later: the size of photoe[]
     1006                          fnpix,    // will be changed by the function!
     1007                          &ncph,    // will be changed by the function!
     1008                          &arrtmin_ns, // will be changed by the function!
     1009                          &arrtmax_ns // will be changed by the function!
     1010                          );
     1011
     1012        if( k != 0 ){ // non-zero returnvalue means error
     1013          cout << "Exiting.\n";
     1014          exit(1);
    10561015        }
    1057 
    1058 //      for( i=0; i<inumphe; i++){
    1059 //        cout << "phe " << photoe[i].ipixnum << " " << photoe[i].iarrtime_ns << "\n";
    1060 //      }
    1061        
    1062         //if ( trigger>0 ) {
    1063         if (Lev1>0){
    1064        
    1065           itrigger = i;
    1066           ++ntrigger;
    1067          
    1068           memcpy( fnpixclean, fnpix, sizeof(float) * ct_NPixels );
    1069         }
    1070         //
    1071         //  Fill the header of this event
    1072         //
    1073        
    1074         Evt->FillHeader ( (UShort_t) (ntshow + nshow) ,  20 ) ;
    1075        
    1076         //
    1077         //   fill the MMcEvt with all information 
    1078         //
    1079        
    1080         McEvt->Fill( (UShort_t) mcevth.get_primary() ,
    1081                      mcevth.get_energy(),
    1082                      mcevth.get_theta(),
    1083                      mcevth.get_phi(),
    1084                      mcevth.get_core(),
    1085                      mcevth.get_coreX(),
    1086                      mcevth.get_coreY(),
    1087                      impactD,
    1088                      ulli, ulli,
    1089                      (UShort_t) ncph,
    1090                      ulli,
    1091                      (UShort_t) ncph) ;
    1092 
    1093         //   We don not count phtons out of the camera.
    1094 
    1095         //
    1096         //    write it out to the file outfile
    1097         //
    1098        
    1099         EvtTree.Fill() ;
    1100        
    1101 
    1102         //
    1103         //    if a first level trigger occurred, then
    1104         //       1. do some other stuff (not implemented)
    1105         //       2. start the gui tool
    1106 
    1107         if(FADC_Scan){
    1108           if ( Lev0 > 0 ) {
    1109             fadc.ShowSignal( McEvt, (Float_t) 60. ) ;
     1016         
     1017        log(SIGNATURE, "End of this event: %d cphs(+%d). . .\n",
     1018            ncph, ntcph);
     1019
     1020        ntcph += ncph;
     1021
     1022        // skip it ?
     1023       
     1024        for ( i=0; i<nSkip; ++i ) {
     1025          if (Skip[i] == (nshow+ntshow)) {
     1026            i = -1;
     1027            break;
    11101028          }
    11111029        }
    1112 
    1113         if(Trigger_Scan){
    1114           if ( Lev0 > 0 ) {
    1115             Trigger.ShowSignal(McEvt) ;
    1116           }
     1030       
     1031        // if after the previous loop, the exit value of i is -1
     1032        // then the shower number is in the list of showers to be
     1033        // skipped
     1034       
     1035        if (i == -1) {
     1036          log(SIGNATURE, "\t\tskipped!\n");
     1037          continue;
    11171038        }
    1118 
    1119         //    clear all
    1120         Evt->Clear() ;
    1121         McEvt->Clear() ;
    1122         McTrig->Clear() ;
    1123      
    1124        
     1039       
     1040        cout << "Total number of phes: " << inumphe <<endl;
     1041
    11251042        //++++++++++++++++++++++++++++++++++++++++++++++++++
    11261043        // at this point we have a camera full of
     
    11321049        // and so on).
    11331050        //--------------------------------------------------
    1134        
     1051         
     1052        // TRIGGER HERE
     1053
     1054
     1055        //
     1056        //   now the noise of the electronic
     1057        //   (preamps, optical transmission,..)  is introduced.
     1058        //   This is done inside the class MTrigger by the method ElecNoise.
     1059        //   
     1060        Trigger.ElecNoise() ;
     1061        fadc.ElecNoise() ;
     1062       
     1063        //   We study several trigger conditons
     1064        if(Trigger_Loop)
     1065
     1066          //  Loop over trigger threshold
     1067          for (ithrescount=Trigger_loop_lthres;ithrescount<=Trigger_loop_uthres;ithrescount++){
     1068            for (i=0;i<TRIGGER_PIXELS;i++)
     1069              fpixelthres[i]=(float) ithrescount;
     1070            Trigger.SetThreshold(fpixelthres);
     1071
     1072            Trigger.Diskriminate();
     1073            //
     1074            //   look if in all the signals in the trigger signal branch
     1075            //   is a possible Trigger. Therefore we habe to diskriminate all
     1076            //   the simulated analog signals (Method Diskriminate in class
     1077            //   MTrigger). We look simultanously for the moments at which
     1078            //   there are more than TRIGGER_MULTI pixels above the
     1079            //   CHANNEL_THRESHOLD.
     1080            //
     1081
     1082            //  loop over multiplicity of trigger configuration
     1083            for (imulticount=Trigger_loop_lmult;imulticount<=Trigger_loop_umult;imulticount++){
     1084              Trigger.SetMultiplicity(imulticount);
     1085              Trigger.ClearZero();
     1086
     1087              Lev0=(Short_t) Trigger.ZeroLevel();
     1088              if (Lev0>0){
     1089                Lev1=Lev2=0;
     1090
     1091                //  loop over topologies
     1092                for(itopocount=Trigger_loop_ltop;itopocount<=Trigger_loop_utop;itopocount++){
     1093                  if(itopocount==0 && imulticount>7) continue;
     1094                  if(itopocount==2 && imulticount<3) continue;
     1095                  Trigger.SetTopology(itopocount);
     1096                  Trigger.ClearFirst();
     1097
     1098                  //
     1099                  //   Start the First Level Trigger simulation
     1100                  //
     1101
     1102                  McTrig->SetFirstLevel (Lev1=Trigger.FirstLevel());
     1103                  if(Lev1>0) {
     1104                    ntriggerloop[ithrescount][imulticount][itopocount]++;
     1105                    McTrig->SetTopology(itopocount);
     1106                    McTrig->SetMultiplicity(imulticount);
     1107                    McTrig->SetThreshold(fpixelthres);
     1108                  }
     1109                  if(Lev1==0 && Write_All_Images){
     1110                    McTrig->SetTopology(itopocount);
     1111                    McTrig->SetMultiplicity(imulticount);
     1112                    McTrig->SetThreshold(fpixelthres);
     1113                    Lev1=1;
     1114                  }
     1115                  for (Int_t ii=0;ii<Lev1;ii++){
     1116                    McTrig->SetTime(Trigger.GetFirstLevelTime(ii));
     1117                    McTrig->SetPixel(Trigger.GetFirstLevelPixel(ii));
     1118                    fadc.TriggeredFadc(Trigger.GetFirstLevelTime(ii));
     1119                    //
     1120                    //  Fill the header of this event
     1121                    //
     1122                   
     1123                    Evt->FillHeader ( (UShort_t) (ntshow + nshow) ,  20 ) ;
     1124                   
     1125                    //   fill pixel information
     1126                   
     1127                    for(i=0;i<iMAXNUMPIX;i++){
     1128                      for (j=0;j<SLICES_MFADC;j++){
     1129                        fadcValues[j]=fadc.GetFadcSignal(i,j);
     1130                      }
     1131                      Evt->FillPixel(i,fadcValues);
     1132                    }
     1133                    //
     1134                    //   fill the MMcEvt with all information 
     1135                    //
     1136                   
     1137                    McEvt->Fill( (UShort_t) mcevth.get_primary() ,
     1138                                 mcevth.get_energy(),
     1139                                 mcevth.get_theta(),
     1140                                 mcevth.get_phi(),
     1141                                 mcevth.get_core(),
     1142                                 mcevth.get_coreX(),
     1143                                 mcevth.get_coreY(),
     1144                                 impactD,
     1145                                 ulli, ulli,
     1146                                 (UShort_t) ncph,
     1147                                 ulli,
     1148                                 (UShort_t) ncph) ;
     1149                   
     1150                    //   We don not count phtons out of the camera.     
     1151
     1152                    //
     1153                    //    write it out to the file outfile
     1154                    //
     1155                   
     1156                    EvtTree.Fill() ;
     1157                    //    clear all
     1158                    Evt->Clear() ;
     1159                    McEvt->Clear() ; 
     1160                   
     1161                  }
     1162                  McTrig->Clear() ;
     1163                }
     1164              }
     1165              else break;
     1166            }
     1167          }
     1168
     1169        //  We study a single trigger condition
     1170        else {
     1171
     1172          Trigger.Diskriminate() ;
     1173
     1174          //
     1175          //   look if in all the signals in the trigger signal branch
     1176          //   is a possible Trigger. Therefore we habe to diskriminate all
     1177          //   the simulated analog signals (Method Diskriminate in class
     1178          //   MTrigger). We look simultanously for the moments at which
     1179          //   there are more than TRIGGER_MULTI pixels above the
     1180          //   CHANNEL_THRESHOLD.
     1181          //
     1182         
     1183          Lev0 = (Short_t) Trigger.ZeroLevel() ;
     1184         
     1185          Lev1 = Lev2 = 0 ;
     1186         
     1187          //
     1188          //   Start the First Level Trigger simulation
     1189          //
     1190         
     1191          if ( Lev0 > 0 ) {
     1192            McTrig->SetFirstLevel (Lev1 = Trigger.FirstLevel());
     1193          }
     1194          if (Lev1>0){
     1195            ++ntrigger;
     1196          }
     1197          if (Lev1==0 && Write_All_Images){
     1198            Lev1=1;
     1199          }
     1200          McTrig->SetTopology(Trigger.GetTopology());
     1201          McTrig->SetMultiplicity(Trigger.GetMultiplicity());
     1202          for(i=0;i<TRIGGER_PIXELS;i++){
     1203            fpixelthres[i]=Trigger.GetThreshold(i);
     1204          }
     1205          McTrig->SetThreshold(fpixelthres);
     1206
     1207          for(Int_t ii=0;ii<Lev1;ii++){
     1208            //  Loop over different level one triggers
     1209            fadc.TriggeredFadc(Trigger.GetFirstLevelTime(ii));
     1210            McTrig->SetTime(Trigger.GetFirstLevelTime(ii));
     1211            McTrig->SetPixel(Trigger.GetFirstLevelPixel(ii));
     1212           
     1213            //
     1214            //  Fill the header of this event
     1215            //
     1216       
     1217            Evt->FillHeader ( (UShort_t) (ntshow + nshow) ,  20 ) ;
     1218           
     1219            //   fill pixel information
     1220           
     1221            for(i=0;i<iMAXNUMPIX;i++){
     1222              for (j=0;j<SLICES_MFADC;j++){
     1223                fadcValues[j]=fadc.GetFadcSignal(i,j);
     1224              }
     1225              Evt->FillPixel(i,fadcValues);
     1226            }
     1227           
     1228            //
     1229            //   fill the MMcEvt with all information 
     1230            //
     1231           
     1232            McEvt->Fill( (UShort_t) mcevth.get_primary() ,
     1233                         mcevth.get_energy(),
     1234                         mcevth.get_theta(),
     1235                         mcevth.get_phi(),
     1236                         mcevth.get_core(),
     1237                         mcevth.get_coreX(),
     1238                         mcevth.get_coreY(),
     1239                         impactD,
     1240                         ulli, ulli,
     1241                         (UShort_t) ncph,
     1242                         ulli,
     1243                         (UShort_t) ncph) ;
     1244           
     1245            //   We don not count photons out of the camera.   
     1246                   
     1247           
     1248            //
     1249            //    write it out to the file outfile
     1250            //
     1251         
     1252            EvtTree.Fill() ;
     1253           
     1254           
     1255            //
     1256            //    if a first level trigger occurred, then
     1257            //       1. do some other stuff (not implemented)
     1258            //       2. start the gui tool
     1259           
     1260            if(FADC_Scan){
     1261              if ( Lev0 > 0 ) {
     1262                fadc.ShowSignal( McEvt, (Float_t) 60. ) ;
     1263              }
     1264            }
     1265           
     1266            if(Trigger_Scan){
     1267              if ( Lev0 > 0 ) {
     1268                Trigger.ShowSignal(McEvt) ;
     1269              }
     1270            }
     1271           
     1272            //    clear all
     1273            Evt->Clear() ;
     1274            McEvt->Clear() ;
     1275          }
     1276          McTrig->Clear() ;
     1277        }
     1278               
    11351279#ifdef __DEBUG__ 
    11361280        printf("\n");
     
    11651309                         
    11661310       
    1167         //!@' @#### Save data.
    1168         //@'
    1169        
    1170         //++++++++++++++++++++++++++++++++++++++++++++++++++
    1171         // we now have all information we want
    1172         // the only thing we must do now is writing it to
    1173         // the output file
    1174         //--------------------------------------------------
    1175        
    1176         //++
    1177         // save the image to the file
    1178         //--
    1179 
    1180 
    1181 
    11821311        // look for the next event
    11831312       
     
    12091338           
    12101339          }
    1211          
     1340
    12121341        } // end if found end of file
    12131342      } // end if found end of run
     
    12261355  outfile.Close() ;
    12271356
    1228   
     1357 
    12291358  // close input file
    12301359 
    12311360  log( SIGNATURE, "%d event(s), with a total of %d C.photons\n",
    12321361       ntshow, ntcph );
    1233   log( SIGNATURE, "Fraction of triggers: %5.1f%% (%d out of %d)\n",
    1234        ((float)ntrigger) / ((float)ntshow) * 100.0, ntrigger, ntshow);
    1235  
     1362  if (Trigger_Loop){
     1363    log( SIGNATURE, "Fraction of triggers: \n");
     1364    for (ithrescount=Trigger_loop_lthres;ithrescount<=Trigger_loop_uthres;ithrescount++){
     1365      for (imulticount=Trigger_loop_lmult;imulticount<=Trigger_loop_umult;imulticount++){
     1366        for(itopocount=Trigger_loop_ltop;itopocount<=Trigger_loop_utop;itopocount++){
     1367          log( SIGNATURE, "Thres %d, Multi %d, Topo %d: %5.1f%% (%d out of %d)\n",
     1368               ithrescount,imulticount,itopocount,((float)ntriggerloop[ithrescount][imulticount][itopocount] / ((float)ntshow) * 100.0), ntriggerloop[ithrescount][imulticount][itopocount], ntshow);
     1369        }
     1370      }   
     1371    }
     1372  }
     1373  else{
     1374    log( SIGNATURE, "Fraction of triggers: %5.1f%% (%d out of %d)\n",
     1375         ((float)ntrigger) / ((float)ntshow) * 100.0, ntrigger, ntshow);
     1376  }
     1377
    12361378  // close files
    12371379 
     
    22342376
    22352377//------------------------------------------------------------
    2236 // @name Photoelectron                         
    2237 //                                     
    2238 // @desc constructor for class Photoelectron
    2239 //
    2240 // @date Mon Feb 15 16:44:21 CET 2000
    2241 // @function @code
    2242 //------------------------------------------------------------
    2243 
    2244 Photoelectron::Photoelectron(void){
    2245   iarrtime_ns = NOTIME;
    2246   ipixnum = -1;
    2247 }
    2248 
    2249 //------------------------------------------------------------
    22502378// @name produce_phes                         
    22512379//                                     
     
    22612389                  float minwl_nm, // the minimum accepted wavelength
    22622390                  float maxwl_nm, // the maximum accepted wavelength
    2263                   class Photoelectron phe[iMAXNUMPHE], // the generated phes
     2391                  class MTrigger *trigger, // the generated phes
     2392                  class MFadc *fadc,
    22642393                  int *itotnphe, // total number of produced photoelectrons
    22652394                  float nphe[iMAXNUMPIX], // number of photoelectrons in each pixel
     
    22762405  static float radius;
    22772406
     2407
    22782408  // reset variables
    22792409
     
    22842414  }
    22852415
    2286   *itotnphe = 0;
    22872416  *incph = 0;
    2288   *tmin_ns = NOTIME; // very big
    2289   *tmax_ns = -NOTIME; // very small
    22902417
    22912418  radius = cam->dxc[cam->inumpixels-1]
     
    23152442         
    23162443    (*incph)++;
    2317                  
     2444
     2445    //  Chceck if photon is inside trigger time range
     2446
     2447    t = photon.get_t() ;
     2448
     2449    if (t-*tmin_ns>TOTAL_TRIGGER_TIME) {
     2450 
     2451     //  read next Photon
     2452         
     2453      fread( flag, SIZE_OF_FLAGS, 1, sp );
     2454     
     2455      // go to beginning of loop, the photon is lost
     2456      continue;
     2457    }
     2458         
    23182459    //
    23192460    // Pixelization
     
    24232564         
    24242565    nphe[ipixnum] += 1.0;
    2425 
    2426     t = photon.get_t() ;
    2427 
    2428     //    cout << " t " << t;
    2429          
    2430     // find minimum and maximum arrival time
    2431 
    2432     if(t < *tmin_ns){
    2433       *tmin_ns = t; // memorize time
    2434     }
    2435     if(t > *tmax_ns){
    2436       *tmax_ns = t; // memorize time
    2437     }
    2438 
     2566         
    24392567    // store the new photoelectron
    24402568
    2441     if(*itotnphe >= iMAXNUMPHE){
    2442       cout << "Error: Memory overflow. Event produces more than maximum\n";
    2443       cout << "       allowed number of photoelectrons (" << iMAXNUMPHE << ").\n";
    2444       return(1);
    2445     }
    2446 
    2447     phe[*itotnphe].iarrtime_ns = (int)t;
    2448     phe[*itotnphe].ipixnum = ipixnum;
    2449          
     2569    fadc->Fill(ipixnum,(t-*tmin_ns) , trigger->FillShow(ipixnum,t-*tmin_ns));
     2570   
    24502571    *itotnphe += 1;
    2451 
     2572   
    24522573    // read next Photon
    24532574         
     
    24732594int produce_nsbrates( char *iname, // the starfield input file name
    24742595                      struct camera *cam, // camera layout
    2475                       class Photoelectron phe[iMAXNUMPHE], // array for photoelectrons
    24762596                      float rate_phepns[iMAXNUMPIX][iNUMWAVEBANDS] // the product of this function:
    24772597                                               // the NSB rates in phe/ns for each pixel
     
    24792599
    24802600  int i, j, k, ii; // counters
     2601
     2602  MTrigger trigger;
     2603  MFadc flashadc;
    24812604                     
    24822605  static float wl_nm[iNUMWAVEBANDS + 1] = { WAVEBANDBOUND1,
     
    25742697                              wl_nm[i],
    25752698                              wl_nm[i+1],
    2576                               phe, // this is a dummy here
     2699                              &trigger,  // this is a dummy here
     2700                              &flashadc, // this is a dummy here
    25772701                              &itnphe,
    25782702                              nphe, // we want this!
     
    26352759                      float extinction[iNUMWAVEBANDS],
    26362760                      float fnpx[iMAXNUMPIX],
    2637                       Photoelectron photo[iMAXNUMPHE],
     2761                      MTrigger *trigger,
     2762                      MFadc *fadc,
    26382763                      int *inphe,
    26392764                      float base_mv[iMAXNUMPIX]){
     
    26442769  int inumnsbphe;   //  number of photoelectrons caused by NSB
    26452770
     2771  float t;
     2772
    26462773  ii = *inphe; // avoid dereferencing
    26472774               
    26482775  // check if the arrival times are set; if not generate them
    26492776
    2650   if(*atmin_ns == NOTIME){
    2651 
     2777  if(*atmin_ns <SIMTIMEOFFSET_NS || *atmin_ns > *atmax_ns){
    26522778    *atmin_ns = 0.;
    2653     *atmax_ns = simtime_ns = SLICES*WIDTH_TIMESLICE;
     2779    *atmax_ns = simtime_ns = TOTAL_TRIGGER_TIME;
    26542780
    26552781  }
     
    26612787    simtime_ns = *atmax_ns - *atmin_ns;
    26622788
    2663     // make sure the simulated time is long enough for the FADC simulation
    2664 
    2665     if(simtime_ns< SLICES*WIDTH_TIMESLICE){
    2666       *atmax_ns = *atmin_ns + SLICES*WIDTH_TIMESLICE;
    2667       simtime_ns = SLICES*WIDTH_TIMESLICE;
     2789    // make sure the simulated time is long enough for the FADC
     2790    // simulation and not too long
     2791
     2792    if(simtime_ns< TOTAL_TRIGGER_TIME){
     2793      *atmin_ns = *atmin_ns -(TOTAL_TRIGGER_TIME-simtime_ns)/2;
     2794      *atmax_ns = *atmin_ns + TOTAL_TRIGGER_TIME;
     2795      simtime_ns = TOTAL_TRIGGER_TIME;
    26682796    }
    2669      
     2797
     2798    if(simtime_ns> TOTAL_TRIGGER_TIME){
     2799      *atmax_ns =*atmin_ns + TOTAL_TRIGGER_TIME;
     2800      simtime_ns = TOTAL_TRIGGER_TIME;
     2801    }
     2802 
    26702803  }
    26712804
     
    26982831     
    26992832      for(k=0; k < inumnsbphe; k++){
    2700 
    2701         if(ii >= iMAXNUMPHE){
    2702           cout << "Error: Memory overflow. NSB simulation produces more than maximum\n";
    2703           cout << "       allowed number of photoelectrons (" << iMAXNUMPHE << ").\n";
    2704           return(1);
    2705         }
    2706 
    2707         photo[ii].iarrtime_ns = (int)(RandomNumber * simtime_ns + *atmin_ns );
    2708         photo[ii].ipixnum = j;
    2709        
    2710         // cout << "Created phe " << photo[ii].iarrtime_ns << " "
    2711         //     << photo[ii].ipixnum << "\n";
     2833       
     2834        t=(RandomNumber * simtime_ns);
     2835
     2836        (*fadc).Fill(j,t ,(*trigger).FillNSB(j,t));
    27122837       
    27132838        ii++; // increment total number of photoelectons
     
    27412866//
    27422867// $Log: not supported by cvs2svn $
     2868// Revision 1.7  2000/03/24 18:10:46  blanch
     2869// A first FADC simulation and a trigger simulation are already implemented.
     2870// The calculation of the Hillas Parameters have been removed, since it was decided that it should be in the analysis software.
     2871// A loop over trigger threshold and some corretcions in the time range where it looks for a trigger will be implemented as soon as possible.
     2872//
    27432873// Revision 1.6  2000/03/20 18:35:11  blanch
    27442874// The trigger is already implemented but it does not save the trigger information in any file as it is implemented in timecam. In the next days there will be a version which also creates the files with the trigger information. It is going to be a mixing of the current camera and timecam programs.
Note: See TracChangeset for help on using the changeset viewer.