Changeset 383
- Timestamp:
- 03/24/00 18:10:46 (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
r379 r383 21 21 // 22 22 // $RCSfile: camera.cxx,v $ 23 // $Revision: 1. 6$23 // $Revision: 1.7 $ 24 24 // $Author: blanch $ 25 // $Date: 2000-03-2 0 18:35:11$25 // $Date: 2000-03-24 18:10:46 $ 26 26 // 27 27 //////////////////////////////////////////////////////////////////////// … … 48 48 49 49 #include "TROOT.h" 50 51 #include "TApplication.h" 50 52 51 53 #include "TFile.h" … … 54 56 #include "TCanvas.h" 55 57 56 #include "MDiag.h" 58 #include "MTrigger.hxx" 59 #include "MFadc.hxx" 57 60 58 61 #include "MRawEvt.h" … … 60 63 #include "MMcTrig.hxx" 61 64 62 #include "MTrigger.hxx"63 64 65 /*!@" 65 66 … … 69 70 70 71 #include "camera.h" 72 71 73 //!@} 72 74 … … 88 90 #undef __DEBUG__ 89 91 92 90 93 //!@} 91 94 … … 196 199 static int Write_All_Data = FALSE; 197 200 201 static int Write_McEvt = TRUE; 202 static int Write_McTrig = FALSE; 203 static int Write_RawEvt = FALSE; 204 198 205 //@: flag: TRUE: selection on the energy 199 206 static int Select_Energy = TRUE; … … 204 211 //@: Upper edge of the selected energy range (in GeV) 205 212 static float Select_Energy_ue = 100000.0; 213 214 //@: flag: TRUE: show all fadc singnal in the screen; FALSE: don't 215 static int FADC_Scan = FALSE; 216 217 //@: flag: TRUE: show all trigger singnal in the screen; FALSE: don't 218 static int Trigger_Scan = FALSE; 206 219 207 220 //!@} … … 319 332 @"*/ 320 333 321 /*!@"322 323 The following are the set of parameters calculated for each image.324 The routines for their calculations are in |moments.cxx|.325 326 @"*/327 328 //!@{329 // parameters of the images330 331 static Moments_Info *moments_ptr;332 static LenWid_Info *lenwid_ptr;333 334 static float *maxs;335 static int *nmaxs;336 static float length, width, dist, xdist, azw, miss, alpha, *conc;337 static float phiasym, asymx, asymy;338 static float charge, smax, maxtrigthr_phe;339 334 340 335 //!@} … … 360 355 char inname[256]; //@< input file name 361 356 char starfieldname[256]; //@< starfield input file name 357 362 358 char datname[256]; //@< data (ASCII) output file name 363 359 char diagname[256]; //@< diagnistic output file (ROOT format) 360 364 361 char rootname[256] ; //@< ROOT file name 365 362 366 363 char parname[256]; //@< parameters file name 364 365 char sign[20]; //@< initialize sign 367 366 368 367 char flag[SIZE_OF_FLAGS + 1]; //@< flags in the .rfl file … … 372 371 373 372 MCEventHeader mcevth; //@< Event Header class (MC) 373 MCCphoton cphoton; //@< Cherenkov Photon class (MC) 374 374 375 375 Photoelectron *photoe = NULL; //@< array of the photoelectrons of one event … … 421 421 int itrigger; //@< index of pixel fired 422 422 int ntrigger = 0; //@< number of triggers in the whole file 423 // MTrigger Trigger ; //@< A instance of the Class MTrigger424 425 // MMcTrig *McTrig = new MMcTrig() ;426 423 427 424 float plateScale_cm2deg; //@< plate scale (deg/cm) … … 508 505 Write_All_Data = get_write_all_data(); 509 506 507 Write_McEvt = get_write_McEvt() ; 508 Write_McTrig = get_write_McTrig() ; 509 Write_RawEvt = get_write_RawEvt() ; 510 511 FADC_Scan = get_FADC_Scan(); 512 Trigger_Scan = get_Trigger_Scan(); 513 510 514 // get filenames 511 515 … … 550 554 "Write_All_Images", ONoff(Write_All_Images), 551 555 "Write_All_Data", ONoff(Write_All_Data)); 556 557 // log flags information 558 559 log(SIGNATURE, 560 "%s:\n\t%20s: %s\n\t%20s: %s\n\t%20s: %s\n", 561 "Root output", 562 "Write_McEvt", ONoff(Write_McEvt), 563 "Write_McTrig", ONoff(Write_McTrig), 564 "Write_RawEvt", ONoff(Write_RawEvt)); 552 565 553 566 // log parameters information … … 597 610 photoe = new Photoelectron[iMAXNUMPHE]; 598 611 612 Int_t Lev0, Lev1, Lev2 ; 613 599 614 // initialise ROOT 600 615 601 616 TROOT simple("simple", "MAGIC Telescope Monte Carlo"); 602 617 603 // prepare ROOT tree for the diagnostic data 604 605 TFile *hfile; 606 607 hfile = new TFile( diagname,"RECREATE", "MAGIC Telescope MC diagnostic data"); 608 609 // Create the ROOT Tree for the diagnostic data 610 611 TTree *tree = new TTree("T","MAGIC Telescope MC diagnostic data"); 612 tree->SetAutoSave(100000000); 613 614 Int_t split = 1; 615 Int_t bsize = 64000; 616 MDiagEventobject *event = 0; 617 618 // Create one branch. If splitlevel is set, event is a superbranch 619 // creating a sub branch for each data member of the Eventobject event. 620 621 tree->Branch("event", "MDiagEventobject", &event, bsize, split); 618 // initialise instance of Trigger and FADC classes 619 620 MTrigger Trigger ; //@< A instance of the Class MTrigger 621 622 MMcTrig *McTrig = new MMcTrig() ; 623 624 MFadc fadc ; //@< A instance of the Class MFadc 625 622 626 623 627 // Prepare the raw data output … … 635 639 TTree EvtTree("EvtTree","Events of Run"); 636 640 637 bsize=128000;split=1;641 Int_t bsize=128000; Int_t split=1; 638 642 639 643 EvtTree.Branch("MRawEvt","MRawEvt", … … 643 647 &McEvt, bsize, split); 644 648 645 649 EvtTree.Branch("MMcTrig","MMcTrig", 650 &McTrig, bsize, split); 651 652 unsigned short ulli = 0 ; 653 654 TApplication theAppTrigger("App", &argc, argv); 655 656 if (gROOT->IsBatch()) { 657 fprintf(stderr, "%s: cannot run in batch mode\n", argv[0]); 658 // return 1; 659 } 660 661 if(FADC_Scan){ 662 TApplication theAppFadc("App", &argc, argv); 663 664 if (gROOT->IsBatch()) { 665 fprintf(stderr, "%s: cannot run in batch mode\n", argv[0]); 666 // return 1; 667 } 668 } 669 646 670 // for safety and for dimensioning image_data: count the elements in the 647 671 // diagnostic data branch … … 720 744 } 721 745 722 // for(i=0; i<cam.inumpixels; i++){723 // cout << i;724 // for(j=0; j<iNUMWAVEBANDS; j++){725 // cout << " " << j << " " << nsbrate_phepns[i][j];726 // }727 // cout << "\n";728 // }729 730 746 // calculate diffuse rate correcting for the pixel size 731 747 … … 780 796 fnpixclean = new float [ ct_NPixels ]; 781 797 782 moments_ptr = moments( anaPixels, NULL, NULL, 0.0, 1 );783 784 798 // initialize baseline 785 799 … … 787 801 baseline_mv[i] = 0.; 788 802 } 789 790 // Instance of the Trigger class791 792 MTrigger Trigger ; //@< A instance of the Class MTrigger793 803 794 804 //!@' @#### Main loop. … … 820 830 821 831 while( isA( flag, FLAG_START_OF_EVENT )){ // while there is a next event 822 832 833 // 834 // Clear Trigger and Fadc 835 // 836 Trigger.Reset() ; 837 fadc.Reset() ; 838 823 839 ++nshow; 824 840 log(SIGNATURE, "Event %d(+%d)\n", nshow, ntshow); … … 999 1015 1000 1016 // 1001 // remove the prviousvalues of the analog signal for1002 // each pixel and put the new onesfrom photoe array1017 // Put values of the analog signal for 1018 // each pixel from photoe array 1003 1019 // 1004 Trigger.Reset();1005 1020 1006 1021 for(i=0;i<inumphe;i++){ 1007 Trigger.FillShow(photoe[i].ipixnum,float((photoe[i].iarrtime_ns-arrtmin_ns+TOTAL_TRIGGER_TIME/10.0))); 1008 } 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 } 1009 1025 1010 1026 // … … 1014 1030 // 1015 1031 Trigger.ElecNoise() ; 1016 1032 fadc.ElecNoise() ; 1033 1034 1035 Trigger.Diskriminate() ; 1036 1017 1037 // 1018 1038 // look if in all the signals in the trigger signal branch … … 1024 1044 // 1025 1045 1026 Trigger.Diskriminate(); 1027 1028 //McTrig->SetZeroLevel(trigger = (Short_t) Trigger.ZeroLevel()) ; 1029 trigger = (Short_t) Trigger.ZeroLevel(); 1046 McTrig->SetZeroLevel( Lev0 = (Short_t) Trigger.ZeroLevel() ) ; 1047 1048 Lev1 = Lev2 = 0 ; 1030 1049 1031 1050 // 1032 1051 // Start the First Level Trigger simulation 1033 1052 // 1034 if ( trigger > 0 ) { 1035 // McTrig->SetFirstLevel ( trigger = Trigger.FirstLevel() ) ; 1036 trigger = Trigger.FirstLevel(); 1037 } 1038 if ( trigger>0 ) { 1039 cout << "TRIG"<<" "<<thetashw <<" "<< trigger << endl; 1053 1054 if ( Lev0 > 0 ) { 1055 McTrig->SetFirstLevel ( Lev1 = Trigger.FirstLevel() ) ; 1040 1056 } 1041 1057 … … 1044 1060 // } 1045 1061 1046 if ( trigger>0 ) { 1047 1062 //if ( trigger>0 ) { 1063 if (Lev1>0){ 1064 1048 1065 itrigger = i; 1049 1066 ++ntrigger; 1050 1067 1051 1068 memcpy( fnpixclean, fnpix, sizeof(float) * ct_NPixels ); 1052 1053 1054 #ifdef __ISLANDS__ 1055 1056 //!@' @#### Islands algorithm. 1057 //@' 1058 1059 //++ 1060 // islands counting, and cleanning 1061 //-- 1062 1063 if ( countIslands ) 1064 do_islands( ct_NPixels, fnpixclean, pixneig, npixneig, 1065 countIslands, nIslandsCut); 1066 1067 #endif // __ISLANDS__ 1068 1069 1070 //!@' @#### Calculation of parameters of the image. 1071 //@' 1072 1073 //++ 1074 // moments calculation 1075 //-- 1076 1077 // calculate moments and other things 1078 1079 moments_ptr = moments( anaPixels, fnpixclean, pixary, 1080 plateScale_cm2deg, 0 ); 1081 1082 charge = moments_ptr->charge ; 1083 smax = moments_ptr->smax ; 1084 maxs = moments_ptr->maxs ; 1085 nmaxs = moments_ptr->nmaxs ; 1086 length = moments_ptr->length ; 1087 width = moments_ptr->width ; 1088 dist = moments_ptr->dist ; 1089 xdist = moments_ptr->xdist ; 1090 azw = moments_ptr->azw ; 1091 miss = moments_ptr->miss ; 1092 alpha = moments_ptr->alpha ; 1093 conc = moments_ptr->conc ; 1094 asymx = moments_ptr->asymx ; 1095 asymx = moments_ptr->asymx ; 1096 phiasym= moments_ptr->phi; 1097 1098 lenwid_ptr = lenwid( anaPixels, fnpixclean, pixary, 1099 plateScale_cm2deg, 1100 ct_PixelWidth_corner_2_corner_half); 1101 1102 1103 // fill the diagnostic Tree 1104 1105 event = new MDiagEventobject(); 1106 1107 i=0; 1108 image_data[i] = event->n = hidt/10; i++; 1109 image_data[i] = event->primary = mcevth.get_primary(); i++; 1110 image_data[i] = event->energy = mcevth.get_energy(); i++; 1111 image_data[i] = event->cored = coreD; i++; 1112 image_data[i] = event->impact = impactD; i++; 1113 image_data[i] = event->xcore = coreX; i++; 1114 image_data[i] = event->ycore = coreY; i++; 1115 image_data[i] = event->theta = mcevth.get_theta(); i++; 1116 image_data[i] = event->phi = mcevth.get_phi(); i++; 1117 image_data[i] = event->deviations = mcevth.get_deviations (&dtheta, &dphi); i++; 1118 image_data[i] = event->dtheta = dtheta; i++; 1119 image_data[i] = event->dphi = dphi; i++; 1120 image_data[i] = event->trigger = trigger; i++; 1121 image_data[i] = event->ncphs = ncph; i++; 1122 image_data[i] = event->maxpassthr_phe = maxtrigthr_phe; i++; 1123 image_data[i] = event->nphes = charge; i++; 1124 image_data[i] = event->nphes2 = smax; i++; 1125 image_data[i] = event->length = length; i++; 1126 image_data[i] = event->width = width; i++; 1127 image_data[i] = event->dist = dist; i++; 1128 image_data[i] = event->xdist = xdist; i++; 1129 image_data[i] = event->azw = azw; i++; 1130 image_data[i] = event->miss = miss; i++; 1131 image_data[i] = event->alpha = alpha; i++; 1132 image_data[i] = event->conc2 = conc[0]; i++; 1133 image_data[i] = event->conc3 = conc[1]; i++; 1134 image_data[i] = event->conc4 = conc[2]; i++; 1135 image_data[i] = event->conc5 = conc[3]; i++; 1136 image_data[i] = event->conc6 = conc[4]; i++; 1137 image_data[i] = event->conc7 = conc[5]; i++; 1138 image_data[i] = event->conc8 = conc[6]; i++; 1139 image_data[i] = event->conc9 = conc[7]; i++; 1140 image_data[i] = event->conc10 = conc[8]; i++; 1141 image_data[i] = event->asymx = asymx; i++; 1142 image_data[i] = event->asymy = asymy; i++; 1143 image_data[i] = event->phiasym = phiasym; i++; 1144 1145 // there should be "nvar" variables 1146 1147 if ( i != nvar ) 1148 error( SIGNATURE, "Wrong entry number for diagnostic data.\n" ); 1149 1150 tree->Fill(); 1151 delete event; 1152 1153 // put information in the data file, 1154 1155 datafile << ntrigger; 1156 for(i=0;i<nvar;i++) { 1157 datafile << ' ' << image_data[i]; 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. ) ; 1158 1110 } 1159 1160 // revert the fnpixclean matrix into fnpix 1161 // (now we do this, but maybe in a future we want to 1162 // use both fnpix and fnpixclean for different things 1163 1164 memcpy( fnpix, fnpixclean, sizeof(float) * ct_NPixels ); 1165 1166 // put this information in the data file, 1167 1168 if ( Write_All_Data ) { 1169 datafile << ' ' << -9999; 1170 for ( i=0; i<ct_NPixels; ++i ) 1171 datafile << ' ' << fnpix[i]; 1111 } 1112 1113 if(Trigger_Scan){ 1114 if ( Lev0 > 0 ) { 1115 Trigger.ShowSignal(McEvt) ; 1172 1116 } 1173 1174 datafile << endl; 1175 1176 mcevth.set_trigger( TRUE ); 1177 1178 log(SIGNATURE, "TRIGGER\n"); 1179 1180 } else { // ( trigger == FALSE ) 1181 1182 event = new MDiagEventobject(); 1183 1184 i=0; 1185 image_data[i] = event->n = hidt/10; i++; 1186 image_data[i] = event->primary = mcevth.get_primary(); i++; 1187 image_data[i] = event->energy = mcevth.get_energy(); i++; 1188 image_data[i] = event->cored = coreD = mcevth.get_core(&coreX, &coreY); i++; 1189 image_data[i] = event->impact = coreD; i++; 1190 image_data[i] = event->xcore = coreX; i++; 1191 image_data[i] = event->ycore = coreY; i++; 1192 image_data[i] = event->theta = mcevth.get_theta(); i++; 1193 image_data[i] = event->phi = mcevth.get_phi(); i++; 1194 image_data[i] = event->deviations = mcevth.get_deviations(&dtheta, &dphi); i++; 1195 image_data[i] = event->dtheta = dtheta; i++; 1196 image_data[i] = event->dphi = dphi; i++; 1197 image_data[i] = event->trigger = trigger; i++; 1198 image_data[i] = event->ncphs = ncph; i++; 1199 image_data[i] = event->maxpassthr_phe = maxtrigthr_phe; i++; 1200 image_data[i] = -1.; i++; 1201 image_data[i] = -1.; i++; 1202 image_data[i] = -1.; i++; 1203 image_data[i] = -1.; i++; 1204 image_data[i] = -1.; i++; 1205 image_data[i] = -1.; i++; 1206 image_data[i] = -1.; i++; 1207 image_data[i] = -1.; i++; 1208 image_data[i] = -1.; i++; 1209 image_data[i] = -1.; i++; 1210 image_data[i] = -1.; i++; 1211 image_data[i] = -1.; i++; 1212 image_data[i] = -1.; i++; 1213 image_data[i] = -1.; i++; 1214 image_data[i] = -1.; i++; 1215 image_data[i] = -1.; i++; 1216 image_data[i] = -1.; i++; 1217 image_data[i] = -1.; i++; 1218 image_data[i] = -1.; i++; 1219 image_data[i] = -1.; i++; 1220 image_data[i] = -1.; i++; 1221 1222 // there should be "nvar" variables 1223 1224 if ( i != nvar ) 1225 error( SIGNATURE, "Wrong entry length for Ntuple.\n" ); 1226 1227 tree->Fill(); 1228 delete event; 1229 1230 // put this information in the data file, 1231 1232 if ( Write_All_Data ) { 1117 } 1118 1119 // clear all 1120 Evt->Clear() ; 1121 McEvt->Clear() ; 1122 McTrig->Clear() ; 1123 1124 1125 //++++++++++++++++++++++++++++++++++++++++++++++++++ 1126 // at this point we have a camera full of 1127 // ph.e.s 1128 // we should first apply the trigger condition, 1129 // and if there's trigger, then clean the image, 1130 // calculate the islands statistics and the 1131 // other parameters of the image (Hillas' parameters 1132 // and so on). 1133 //-------------------------------------------------- 1134 1135 #ifdef __DEBUG__ 1136 printf("\n"); 1137 1138 for ( ici=0; ici<PIX_ARRAY_SIDE; ++ici ) { 1139 1140 for ( icj=0; icj<PIX_ARRAY_SIDE; ++icj ) { 1233 1141 1234 datafile << ntrigger; 1235 for ( i=0; i<nvar; ++i ) 1236 datafile << ' ' << image_data[i]; 1237 1238 datafile << -9999; 1239 for ( i=0; i<ct_NPixels; ++i ) 1240 datafile << ' ' << fnpix[i]; 1241 1242 datafile << endl; 1142 if ( (int)pixels[ici][icj][PIXNUM] > -1 ) { 1143 1144 if ( fnpix[(int)pixels[ici][icj][PIXNUM]] > 0. ) { 1145 1146 printf ("@@ %4d %4d %10f %10f %4f (%4d %4d)\n", nshow, 1147 (int)pixels[ici][icj][PIXNUM], 1148 pixels[ici][icj][PIXX], 1149 pixels[ici][icj][PIXY], 1150 fnpix[(int)pixels[ici][icj][PIXNUM]], ici, icj); 1151 1152 } 1153 } 1243 1154 } 1244 1245 mcevth.set_trigger( FALSE ); 1246 1247 } // trigger == FALSE 1248 1155 } 1156 1157 for (i=0; i<ct_NPixels; ++i) { 1158 printf("%d (%d): ", i, npixneig[i]); 1159 for (j=0; j<npixneig[i]; ++i) 1160 printf(" %d", pixneig[i][j]); 1161 printf("\n"); 1162 } 1163 1164 #endif // __DEBUG__ 1165 1166 1249 1167 //!@' @#### Save data. 1250 1168 //@' … … 1324 1242 } 1325 1243 datafile.close(); 1326 1327 hfile->Write();1328 1329 hfile->Close();1330 1244 1331 1245 // program finished … … 2827 2741 // 2828 2742 // $Log: not supported by cvs2svn $ 2743 // Revision 1.6 2000/03/20 18:35:11 blanch 2744 // 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. 2745 // 2829 2746 // Revision 1.5 2000/02/18 17:40:35 petry 2830 2747 // This version includes drastic changes compared to camera.cxx 1.4.
Note:
See TracChangeset
for help on using the changeset viewer.