Changeset 408
- Timestamp:
- 07/04/00 15:10:20 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
r402 r408 21 21 // 22 22 // $RCSfile: camera.cxx,v $ 23 // $Revision: 1. 9$24 // $Author: blanch$25 // $Date: 2000-0 6-13 13:25:24$23 // $Revision: 1.10 $ 24 // $Author: MagicSol $ 25 // $Date: 2000-07-04 14:10:20 $ 26 26 // 27 27 //////////////////////////////////////////////////////////////////////// … … 200 200 201 201 static int Write_McEvt = TRUE; 202 static int Write_McTrig = FALSE;202 static int Write_McTrig = TRUE; 203 203 static int Write_RawEvt = FALSE; 204 204 … … 220 220 //@: flag: TRUE: loop trigger analysis over several thresholds, multiplicities and topologies; FALSE: a single trigger configuration 221 221 static int Trigger_Loop = FALSE; 222 223 //@: Properties of the trigger 224 static float Trigger_gate_length = 3.0; 225 static float Trigger_response_ampl = 1.0; 226 static float Trigger_response_fwhm = 2.0; 227 228 //@: Trigger conditions for a single trigger mode 229 static float Trigger_threshold = 7.0; 230 static int Trigger_multiplicity = 4; 231 static int Trigger_topology = 2; 222 232 223 233 //@: Upper and lower edges of the trigger loop … … 368 378 369 379 char datname[256]; //@< data (ASCII) output file name 370 char diagname[256]; //@< diagnistic output file (ROOT format)371 380 372 381 char rootname[256] ; //@< ROOT file name 382 char rootname_loop[256] ; //@< ROOT file name 373 383 374 384 char parname[256]; //@< parameters file name 375 376 char sign[20]; //@< initialize sign377 385 378 386 char flag[SIZE_OF_FLAGS + 1]; //@< flags in the .rfl file … … 428 436 float fCorrection; //@< Factor to apply to pixel values (def. 1.) 429 437 430 int trigger; //@< trigger flag431 int itrigger; //@< index of pixel fired432 438 int ntrigger = 0; //@< number of triggers in the whole file 433 439 int ithrescount; //@< counter for loop over threshold trigger … … 441 447 float degTriggerZone; //@< trigger area in the camera (radius, in deg.) 442 448 443 float dtheta, dphi; //@< deviations of CT from shower axis444 445 449 int still_in_loop = FALSE; 446 447 float *image_data;448 int nvar, hidt;449 450 450 451 struct camera cam; // structure holding the camera definition … … 527 528 FADC_Scan = get_FADC_Scan(); 528 529 Trigger_Scan = get_Trigger_Scan(); 530 531 get_Trigger_properties( &Trigger_gate_length, &Trigger_response_ampl, &Trigger_response_fwhm); 532 529 533 Trigger_Loop = get_Trigger_Loop(&Trigger_loop_lthres, &Trigger_loop_uthres, &Trigger_loop_lmult, &Trigger_loop_umult, &Trigger_loop_ltop, &Trigger_loop_utop); 530 534 535 if (!Trigger_Loop){ 536 get_Trigger_Single (&Trigger_threshold, &Trigger_multiplicity, &Trigger_topology); 537 } 531 538 532 539 // get filenames … … 535 542 strcpy( starfieldname, get_starfield_filename() ); 536 543 strcpy( datname, get_data_filename() ); 537 strcpy( diagname, get_diag_filename() );538 544 strcpy( rootname, get_root_filename() ); 545 strcpy( rootname_loop, get_loop_filename() ); 539 546 strcpy( ct_filename, get_ct_filename() ); 540 547 … … 553 560 554 561 log(SIGNATURE, 555 "%s:\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 \t%20s:\t%s\n",562 "%s:\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", 556 563 "Filenames", 557 564 "In", inname, … … 559 566 "CT", ct_filename, 560 567 "Data", datname, 561 "Diag", diagname,562 568 "ROOT", rootname 563 569 ); 564 570 565 571 // log Trigger information 572 573 if (Trigger_Loop) { 574 log(SIGNATURE, 575 "%s:\n\t%20s: %i - %i\n\t%20s: %i - %i\n\t%20s: %i - %i\n\t%20s\n", 576 "Trigger Loop mode", 577 "Threshold",Trigger_loop_lthres,Trigger_loop_uthres, 578 "Multiplicity",Trigger_loop_lmult,Trigger_loop_umult, 579 "Topology",Trigger_loop_ltop,Trigger_loop_utop, 580 rootname_loop); 581 } 582 else{ 583 log(SIGNATURE, 584 "%s:\n\t%20s: %f\n\t%20s: %i\n\t%20s: %i\n", 585 "Single Trigger mode", 586 "Threshold",Trigger_threshold, 587 "Multiplicity",Trigger_multiplicity, 588 "Topology",Trigger_topology); 589 } 590 566 591 // log flags information 567 592 … … 630 655 log(SIGNATURE, "\tshower # %d\n", Skip[i]); 631 656 } 657 632 658 633 659 // read parameters from the ct.def file … … 647 673 // initialise instance of Trigger and FADC classes 648 674 649 MTrigger Trigger 675 MTrigger Trigger(Trigger_gate_length, Trigger_response_ampl, Trigger_response_fwhm); //@< A instance of the Class MTrigger 650 676 651 677 MMcTrig *McTrig = new MMcTrig() ; … … 659 685 MMcEvt *McEvt = new MMcEvt (); 660 686 661 // initalize the ROOT file 687 // 688 // initalize a temporal ROOT file 662 689 // 663 664 TFile outfile ( rootname , "RECREATE" ); 665 690 691 TFile outfile_temp ( rootname , "RECREATE" ); 692 693 666 694 // create a Tree for the Event data stream 667 668 695 TTree EvtTree("EvtTree","Events of Run"); 669 696 670 697 Int_t bsize=128000; Int_t split=1; 671 698 672 EvtTree.Branch("MRawEvt","MRawEvt", 673 &Evt, bsize, split); 699 if(!Trigger_Loop){ 700 701 EvtTree.Branch("MRawEvt","MRawEvt", 702 &Evt, bsize, split); 703 } 674 704 675 705 EvtTree.Branch("MMcEvt","MMcEvt", 676 677 706 &McEvt, bsize, split); 707 678 708 EvtTree.Branch("MMcTrig","MMcTrig", 679 &McTrig, bsize, split); 709 &McTrig, bsize, split); 710 711 712 // create a Tree for the Event data stream 713 TTree EvtTree_loop("EvtTree","Events of Run"); 714 715 if (Trigger_Loop && Write_RawEvt){ 716 717 EvtTree_loop.Branch("MRawEvt","MRawEvt", 718 &Evt, bsize, split); 719 720 EvtTree_loop.Branch("MMcEvt","MMcEvt", 721 &McEvt, bsize, split); 722 723 EvtTree_loop.Branch("MMcTrig","MMcTrig", 724 &McTrig, bsize, split); 725 726 } 680 727 681 728 unsigned short ulli = 0 ; … … 697 744 } 698 745 699 // for safety and for dimensioning image_data: count the elements in the700 // diagnostic data branch701 702 i=0;703 i++; // "n"704 i++; // "primary"705 i++; // "energy"706 i++; // "cored"707 i++; // "impact"708 i++; // "xcore"709 i++; // "ycore"710 i++; // "theta"711 i++; // "phi"712 i++; // "deviations"713 i++; // "dtheta"714 i++; // "dphi"715 i++; // "trigger"716 i++; // "ncphs"717 i++; // "maxpassthr_phe"718 i++; // "nphes"719 i++; // "nphes2"720 i++; // "length"721 i++; // "width"722 i++; // "dist"723 i++; // "xdist"724 i++; // "azw"725 i++; // "miss"726 i++; // "alpha"727 i++; // "conc2"728 i++; // "conc3"729 i++; // "conc4"730 i++; // "conc5"731 i++; // "conc6"732 i++; // "conc7"733 i++; // "conc8"734 i++; // "conc9"735 i++; // "conc10"736 i++; // "asymx"737 i++; // "asymy"738 i++; // "phiasym"739 740 nvar = i;741 image_data = new float[nvar];742 743 746 // set plate scale (deg/cm) and trigger area (deg) 744 747 … … 849 852 // reading .rfl files 850 853 if(!isA( flag, FLAG_START_OF_RUN )){ 854 855 //We write some trigger information in data file before exit 856 857 datafile<<ntshow<<" event(s), with a total of "<<ntcph<<" C.photons"<<endl; 858 if (Trigger_Loop){ 859 datafile<<"Fraction of triggers: "<<endl; 860 for (ithrescount=Trigger_loop_lthres;ithrescount<=Trigger_loop_uthres;ithrescount++){ 861 for (imulticount=Trigger_loop_lmult;imulticount<=Trigger_loop_umult;imulticount++){ 862 for(itopocount=Trigger_loop_ltop;itopocount<=Trigger_loop_utop;itopocount++){ 863 datafile<<"Thres "<<ithrescount<<", Multi "<<imulticount<<", Topo"<<itopocount<<": "; 864 datafile<<((float)ntriggerloop[ithrescount-Trigger_loop_lthres][imulticount-Trigger_loop_lmult][itopocount-Trigger_loop_ltop] / ((float)ntshow) * 100.0)<<"% ("<<ntriggerloop[ithrescount-Trigger_loop_lthres][imulticount-Trigger_loop_lmult][itopocount-Trigger_loop_ltop]<<" out of "<<ntshow<<")"<<endl; 865 } 866 } 867 } 868 } 869 else{ 870 datafile<<"Fraction of triggers: "<<((float)ntrigger) / ((float)ntshow) * 100.0<<" ("<<ntrigger<<" out of "<<ntshow<<" )"<<endl; 871 } 872 // We exit 851 873 error( SIGNATURE, "Expected start of run flag, but found: %s\n", flag ); 852 874 } … … 1065 1087 1066 1088 // We study several trigger conditons 1067 if(Trigger_Loop) 1068 1089 if(Trigger_Loop){ 1069 1090 // Loop over trigger threshold 1070 1091 for (ithrescount=Trigger_loop_lthres;ithrescount<=Trigger_loop_uthres;ithrescount++){ … … 1089 1110 1090 1111 Lev0=(Short_t) Trigger.ZeroLevel(); 1091 if (Lev0>0 ){1112 if (Lev0>0 || Write_All_Images){ 1092 1113 Lev1=Lev2=0; 1093 1114 … … 1102 1123 // Start the First Level Trigger simulation 1103 1124 // 1104 1105 1125 McTrig->SetFirstLevel (Lev1=Trigger.FirstLevel()); 1106 1126 if(Lev1>0) { … … 1108 1128 McTrig->SetTopology(itopocount); 1109 1129 McTrig->SetMultiplicity(imulticount); 1110 McTrig->SetThreshold(fpixelthres); 1130 McTrig->SetThreshold(fpixelthres); 1111 1131 } 1112 1132 if(Lev1==0 && Write_All_Images){ … … 1120 1140 McTrig->SetPixel(Trigger.GetFirstLevelPixel(ii)); 1121 1141 fadc.TriggeredFadc(Trigger.GetFirstLevelTime(ii)); 1122 // 1123 // Fill the header of this event 1124 // 1125 1126 Evt->FillHeader ( (UShort_t) (ntshow + nshow) , 20 ) ; 1127 1142 1128 1143 // fill pixel information 1129 1144 … … 1132 1147 fadcValues[j]=fadc.GetFadcSignal(i,j); 1133 1148 } 1149 } 1150 1151 if( Write_RawEvt ){ 1152 // 1153 // Fill the header of this event 1154 // 1155 1156 Evt->FillHeader ( (UShort_t) (ntshow + nshow) , 20 ) ; 1157 1158 // fill pixel information 1159 1134 1160 Evt->FillPixel(i,fadcValues); 1161 1162 // 1163 // fill the MMcEvt with all information 1164 // 1165 1166 McEvt->Fill( (UShort_t) mcevth.get_primary() , 1167 mcevth.get_energy(), 1168 mcevth.get_theta(), 1169 mcevth.get_phi(), 1170 mcevth.get_core(), 1171 mcevth.get_coreX(), 1172 mcevth.get_coreY(), 1173 impactD, 1174 ulli, ulli, 1175 (UShort_t) ncph, 1176 ulli, 1177 (UShort_t) ncph) ; 1178 // We don not count phtons out of the camera. 1179 1180 // 1181 // write it out to the file outfile 1182 // 1183 1184 EvtTree_loop.Fill() ; 1185 1186 // clear all 1187 Evt->Clear() ; 1188 McEvt->Clear() ; 1135 1189 } 1136 //1137 // fill the MMcEvt with all information1138 //1139 1140 McEvt->Fill( (UShort_t) mcevth.get_primary() ,1141 mcevth.get_energy(),1142 mcevth.get_theta(),1143 mcevth.get_phi(),1144 mcevth.get_core(),1145 mcevth.get_coreX(),1146 mcevth.get_coreY(),1147 impactD,1148 ulli, ulli,1149 (UShort_t) ncph,1150 ulli,1151 (UShort_t) ncph) ;1152 1153 // We don not count phtons out of the camera.1154 1155 //1156 // write it out to the file outfile1157 //1158 1159 EvtTree.Fill() ;1160 // clear all1161 Evt->Clear() ;1162 McEvt->Clear() ;1163 1164 1190 } 1191 // 1192 // fill the MMcEvt with all information 1193 // 1194 1195 McEvt->Fill( (UShort_t) mcevth.get_primary() , 1196 mcevth.get_energy(), 1197 mcevth.get_theta(), 1198 mcevth.get_phi(), 1199 mcevth.get_core(), 1200 mcevth.get_coreX(), 1201 mcevth.get_coreY(), 1202 impactD, 1203 ulli, ulli, 1204 (UShort_t) ncph, 1205 ulli, 1206 (UShort_t) ncph) ; 1207 1208 EvtTree.Fill() ; 1209 1165 1210 McTrig->Clear() ; 1166 1211 } … … 1169 1214 } 1170 1215 } 1171 1216 } 1172 1217 // We study a single trigger condition 1173 1218 else { 1174 1219 1220 // Setting trigger conditions 1221 Trigger.SetMultiplicity(Trigger_multiplicity); 1222 Trigger.SetTopology(Trigger_topology); 1223 for (i=0;i<TRIGGER_PIXELS;i++) 1224 fpixelthres[i]=Trigger_threshold; 1225 Trigger.SetThreshold(fpixelthres); 1226 1175 1227 Trigger.Diskriminate() ; 1176 1228 … … 1192 1244 // 1193 1245 1194 if ( Lev0 > 0 ) {1195 McTrig->SetFirstLevel (Lev1 1246 if ( Lev0 > 0 || Write_All_Images) { 1247 McTrig->SetFirstLevel (Lev1= Trigger.FirstLevel()); 1196 1248 } 1197 1249 if (Lev1>0){ … … 1217 1269 // Fill the header of this event 1218 1270 // 1219 1271 1220 1272 Evt->FillHeader ( (UShort_t) (ntshow + nshow) , 20 ) ; 1221 1273 … … 1247 1299 1248 1300 // We don not count photons out of the camera. 1249 1301 1250 1302 1251 1303 // 1252 1304 // write it out to the file outfile 1253 1305 // 1254 1306 1255 1307 EvtTree.Fill() ; 1256 1308 1257 1309 1310 1258 1311 // 1259 1312 // if a first level trigger occurred, then … … 1353 1406 // put the Event to the root file 1354 1407 //-- 1355 1408 1409 EvtTree.Write() ; 1410 outfile_temp.Write() ; 1411 outfile_temp.Close() ; 1412 1413 // 1414 // initalize the ROOT file 1415 // 1416 1417 TFile outfile ( rootname , "RECREATE" ); 1356 1418 EvtTree.Write() ; 1357 1419 outfile.Write() ; 1358 1420 outfile.Close() ; 1359 1421 1360 1422 if(Trigger_Loop && Write_RawEvt){ 1423 //++ 1424 // put the Event to the special root file 1425 //-- 1426 TFile outfile_loop( rootname_loop , "RECREATE" ); 1427 EvtTree_loop.Write() ; 1428 outfile_loop.Write() ; 1429 1430 outfile_loop.Close() ; 1431 } 1361 1432 // close input file 1362 1433 1363 1434 log( SIGNATURE, "%d event(s), with a total of %d C.photons\n", 1364 1435 ntshow, ntcph ); 1436 datafile<<ntshow<<" event(s), with a total of "<<ntcph<<" C.photons"<<endl; 1365 1437 if (Trigger_Loop){ 1438 log( SIGNATURE, "Trigger Mode. \n"); 1366 1439 log( SIGNATURE, "Fraction of triggers: \n"); 1440 datafile<<"Fraction of triggers: "<<endl; 1367 1441 for (ithrescount=Trigger_loop_lthres;ithrescount<=Trigger_loop_uthres;ithrescount++){ 1368 1442 for (imulticount=Trigger_loop_lmult;imulticount<=Trigger_loop_umult;imulticount++){ … … 1370 1444 log( SIGNATURE, "Thres %d, Multi %d, Topo %d: %5.1f%% (%d out of %d)\n", 1371 1445 ithrescount,imulticount,itopocount,((float)ntriggerloop[ithrescount-Trigger_loop_lthres][imulticount-Trigger_loop_lmult][itopocount-Trigger_loop_ltop] / ((float)ntshow) * 100.0), ntriggerloop[ithrescount-Trigger_loop_lthres][imulticount-Trigger_loop_lmult][itopocount-Trigger_loop_ltop], ntshow); 1446 datafile<<"Thres "<<ithrescount<<", Multi "<<imulticount<<", Topo"<<itopocount<<": "; 1447 datafile<<((float)ntriggerloop[ithrescount-Trigger_loop_lthres][imulticount-Trigger_loop_lmult][itopocount-Trigger_loop_ltop] / ((float)ntshow) * 100.0)<<"% ("<<ntriggerloop[ithrescount-Trigger_loop_lthres][imulticount-Trigger_loop_lmult][itopocount-Trigger_loop_ltop]<<" out of "<<ntshow<<")"<<endl; 1372 1448 } 1373 1449 } … … 1377 1453 log( SIGNATURE, "Fraction of triggers: %5.1f%% (%d out of %d)\n", 1378 1454 ((float)ntrigger) / ((float)ntshow) * 100.0, ntrigger, ntshow); 1455 datafile<<"Fraction of triggers: "<<((float)ntrigger) / ((float)ntshow) * 100.0<<" ("<<ntrigger<<" out of "<<ntshow<<" )"<<endl; 1379 1456 } 1380 1457 … … 2603 2680 int i, j, k, ii; // counters 2604 2681 2605 MTrigger trigger ;2682 MTrigger trigger(Trigger_gate_length, Trigger_response_ampl, Trigger_response_fwhm); 2606 2683 MFadc flashadc; 2607 2684 … … 2630 2707 2631 2708 infile = fopen( iname, "r" ); 2632 if ( infile == NULL ) 2633 error( SIGNATURE, "Cannot open starfield input file: %s\n", iname ); 2709 2710 // check if the satrfield input file exists 2711 2712 if ( infile == NULL ) { 2713 2714 log( SIGNATURE, "Cannot open starfield input file: %s\n", iname ); 2715 2716 log( SIGNATURE, "There is not NSB from the Stars\n"); 2717 2718 return (0); 2719 } 2634 2720 2635 2721 // get signature, and check it … … 2869 2955 // 2870 2956 // $Log: not supported by cvs2svn $ 2957 // Revision 1.9 2000/06/13 13:25:24 blanch 2958 // The multiple arrays have been replaced, since they do not work 2959 // in alpha machines. Now we are using pointers and the command new 2960 // to allocate memory. 2961 // 2871 2962 // Revision 1.8 2000/05/11 13:57:27 blanch 2872 2963 // The option to loop over several trigger configurations has been included.
Note:
See TracChangeset
for help on using the changeset viewer.