Changeset 388 for trunk/MagicSoft/Simulation/Detector
- Timestamp:
- 05/11/00 14:57:27 (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
r383 r388 21 21 // 22 22 // $RCSfile: camera.cxx,v $ 23 // $Revision: 1. 7$23 // $Revision: 1.8 $ 24 24 // $Author: blanch $ 25 // $Date: 2000-0 3-24 18:10:46$25 // $Date: 2000-05-11 13:57:27 $ 26 26 // 27 27 //////////////////////////////////////////////////////////////////////// … … 217 217 //@: flag: TRUE: show all trigger singnal in the screen; FALSE: don't 218 218 static int Trigger_Scan = FALSE; 219 220 //@: flag: TRUE: loop trigger analysis over several thresholds, multiplicities and topologies; FALSE: a single trigger configuration 221 static int Trigger_Loop = FALSE; 222 223 //@: Upper and lower edges of the trigger loop 224 static int Trigger_loop_lthres = 0; 225 static int Trigger_loop_uthres = 10; 226 static int Trigger_loop_lmult = 2; 227 static int Trigger_loop_umult = 10; 228 static int Trigger_loop_ltop = 0; 229 static int Trigger_loop_utop = 2; 219 230 220 231 //!@} … … 373 384 MCCphoton cphoton; //@< Cherenkov Photon class (MC) 374 385 375 Photoelectron *photoe = NULL; //@< array of the photoelectrons of one event376 386 int inumphe; //@< number of photoelectrons in an event 377 387 … … 421 431 int itrigger; //@< index of pixel fired 422 432 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 423 439 424 440 float plateScale_cm2deg; //@< plate scale (deg/cm) … … 511 527 FADC_Scan = get_FADC_Scan(); 512 528 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 513 531 514 532 // get filenames … … 581 599 "Energy", ONoff(Select_Energy), Select_Energy_le, Select_Energy_ue); 582 600 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 583 613 // set all random numbers seeds 584 614 … … 605 635 606 636 read_pixels(&cam); 607 608 // allocate memory for the photoelectrons609 610 photoe = new Photoelectron[iMAXNUMPHE];611 637 612 638 Int_t Lev0, Lev1, Lev2 ; … … 737 763 k = produce_nsbrates( starfieldname, 738 764 &cam, 739 photoe, // only a dummy here740 765 nsbrate_phepns ); 741 766 if (k != 0){ … … 835 860 // 836 861 Trigger.Reset() ; 862 Trigger.ClearFirst(); 863 Trigger.ClearZero(); 837 864 fadc.Reset() ; 838 865 … … 928 955 } 929 956 930 // read the photons and produce the photoelectrons931 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 error945 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 -1964 // then the shower number is in the list of showers to be965 // skipped966 967 if (i == -1) {968 log(SIGNATURE, "\t\tskipped!\n");969 continue;970 }971 972 957 // energy cut 973 958 … … 979 964 } 980 965 } 966 967 // Read first and last time and put inumphe to 0 968 969 mcevth.get_times(&arrtmin_ns,&arrtmax_ns); 970 inumphe=0; 981 971 982 972 // NSB simulation … … 992 982 ext, 993 983 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! 995 986 &inumphe, // important for later: the size of photoe[] 996 987 baseline_mv // will be generated by the function … … 1001 992 exit(1); 1002 993 } 1003 994 1004 995 }// end if(simulateNSB) ... 1005 996 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); 1056 1015 } 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; 1110 1028 } 1111 1029 } 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; 1117 1038 } 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 1125 1042 //++++++++++++++++++++++++++++++++++++++++++++++++++ 1126 1043 // at this point we have a camera full of … … 1132 1049 // and so on). 1133 1050 //-------------------------------------------------- 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 1135 1279 #ifdef __DEBUG__ 1136 1280 printf("\n"); … … 1165 1309 1166 1310 1167 //!@' @#### Save data.1168 //@'1169 1170 //++++++++++++++++++++++++++++++++++++++++++++++++++1171 // we now have all information we want1172 // the only thing we must do now is writing it to1173 // the output file1174 //--------------------------------------------------1175 1176 //++1177 // save the image to the file1178 //--1179 1180 1181 1182 1311 // look for the next event 1183 1312 … … 1209 1338 1210 1339 } 1211 1340 1212 1341 } // end if found end of file 1213 1342 } // end if found end of run … … 1226 1355 outfile.Close() ; 1227 1356 1228 1357 1229 1358 // close input file 1230 1359 1231 1360 log( SIGNATURE, "%d event(s), with a total of %d C.photons\n", 1232 1361 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 1236 1378 // close files 1237 1379 … … 2234 2376 2235 2377 //------------------------------------------------------------ 2236 // @name Photoelectron2237 //2238 // @desc constructor for class Photoelectron2239 //2240 // @date Mon Feb 15 16:44:21 CET 20002241 // @function @code2242 //------------------------------------------------------------2243 2244 Photoelectron::Photoelectron(void){2245 iarrtime_ns = NOTIME;2246 ipixnum = -1;2247 }2248 2249 //------------------------------------------------------------2250 2378 // @name produce_phes 2251 2379 // … … 2261 2389 float minwl_nm, // the minimum accepted wavelength 2262 2390 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, 2264 2393 int *itotnphe, // total number of produced photoelectrons 2265 2394 float nphe[iMAXNUMPIX], // number of photoelectrons in each pixel … … 2276 2405 static float radius; 2277 2406 2407 2278 2408 // reset variables 2279 2409 … … 2284 2414 } 2285 2415 2286 *itotnphe = 0;2287 2416 *incph = 0; 2288 *tmin_ns = NOTIME; // very big2289 *tmax_ns = -NOTIME; // very small2290 2417 2291 2418 radius = cam->dxc[cam->inumpixels-1] … … 2315 2442 2316 2443 (*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 2318 2459 // 2319 2460 // Pixelization … … 2423 2564 2424 2565 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 2439 2567 // store the new photoelectron 2440 2568 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 2450 2571 *itotnphe += 1; 2451 2572 2452 2573 // read next Photon 2453 2574 … … 2473 2594 int produce_nsbrates( char *iname, // the starfield input file name 2474 2595 struct camera *cam, // camera layout 2475 class Photoelectron phe[iMAXNUMPHE], // array for photoelectrons2476 2596 float rate_phepns[iMAXNUMPIX][iNUMWAVEBANDS] // the product of this function: 2477 2597 // the NSB rates in phe/ns for each pixel … … 2479 2599 2480 2600 int i, j, k, ii; // counters 2601 2602 MTrigger trigger; 2603 MFadc flashadc; 2481 2604 2482 2605 static float wl_nm[iNUMWAVEBANDS + 1] = { WAVEBANDBOUND1, … … 2574 2697 wl_nm[i], 2575 2698 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 2577 2701 &itnphe, 2578 2702 nphe, // we want this! … … 2635 2759 float extinction[iNUMWAVEBANDS], 2636 2760 float fnpx[iMAXNUMPIX], 2637 Photoelectron photo[iMAXNUMPHE], 2761 MTrigger *trigger, 2762 MFadc *fadc, 2638 2763 int *inphe, 2639 2764 float base_mv[iMAXNUMPIX]){ … … 2644 2769 int inumnsbphe; // number of photoelectrons caused by NSB 2645 2770 2771 float t; 2772 2646 2773 ii = *inphe; // avoid dereferencing 2647 2774 2648 2775 // check if the arrival times are set; if not generate them 2649 2776 2650 if(*atmin_ns == NOTIME){ 2651 2777 if(*atmin_ns <SIMTIMEOFFSET_NS || *atmin_ns > *atmax_ns){ 2652 2778 *atmin_ns = 0.; 2653 *atmax_ns = simtime_ns = SLICES*WIDTH_TIMESLICE;2779 *atmax_ns = simtime_ns = TOTAL_TRIGGER_TIME; 2654 2780 2655 2781 } … … 2661 2787 simtime_ns = *atmax_ns - *atmin_ns; 2662 2788 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; 2668 2796 } 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 2670 2803 } 2671 2804 … … 2698 2831 2699 2832 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)); 2712 2837 2713 2838 ii++; // increment total number of photoelectons … … 2741 2866 // 2742 2867 // $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 // 2743 2873 // Revision 1.6 2000/03/20 18:35:11 blanch 2744 2874 // 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.