Changeset 646
- Timestamp:
- 02/23/01 11:05:57 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
r577 r646 21 21 // 22 22 // $RCSfile: camera.cxx,v $ 23 // $Revision: 1.1 6$23 // $Revision: 1.17 $ 24 24 // $Author: magicsol $ 25 // $Date: 2001-0 1-18 18:44:40$25 // $Date: 2001-02-23 11:05:57 $ 26 26 // 27 27 //////////////////////////////////////////////////////////////////////// … … 61 61 #include "MTrigger.hxx" 62 62 #include "MFadc.hxx" 63 #include "MLons.hxx" 63 64 64 65 #include "MRawEvtData.h" … … 67 68 #include "MMcEvt.hxx" 68 69 #include "MMcTrig.hxx" 69 #include "MHeaderTrig.hxx" 70 #include "MMcTrigHeader.hxx" 71 #include "MMcFadcHeader.hxx" 70 72 71 73 /*!@" … … 272 274 //@: contents of the pixels (ph.e.) 273 275 static float *fnpix; 274 275 //@: contents of the pixels (ph.e.) after cleanning276 static float *fnpixclean;277 276 278 277 … … 391 390 char parname[256]; //@< parameters file name 392 391 392 char nsbpathname[256]; //@< directory with the dataabse for th NSB 393 393 394 char flag[SIZE_OF_FLAGS + 1]; //@< flags in the .rfl file 394 395 … … 399 400 MCCphoton cphoton; //@< Cherenkov Photon class (MC) 400 401 401 int inumphe; //@< number of photoelectrons in an event 402 int inumphe; //@< number of photoelectrons in an event from showers 403 float inumphensb; //@< number of photoelectrons in an event from nsb 402 404 403 405 float arrtmin_ns; //@ arrival time of the first photoelectron … … 406 408 float thetaCT, phiCT; //@< parameters of a given shower 407 409 float thetashw, phishw; //@< parameters of a given shower 408 float coreD, coreX, coreY; //@< core position and distance410 float coreD, coreX, coreY; //@< core position 409 411 float impactD; //@< impact parameter 410 412 float l1, m1, n1; //@< auxiliary variables 411 413 float l2, m2, n2; //@< auxiliary variables 412 float num, den; 414 float num, den; //@< auxiliary variables 413 415 414 416 int nshow=0; //@< partial number of shower in a given run … … 425 427 float nsbrate_phepns[iMAXNUMPIX][iNUMWAVEBANDS]; //@< non-diffuse nsb 426 428 //@< photoelectron rates 429 float nsb_phepns[iMAXNUMPIX]; //@< NSB values for each pixel 430 431 Float_t nsb_trigresp[TRIGGER_TIME_SLICES]; //@< array to write the trigger 432 //@< response from the database 433 Float_t nsb_fadcresp[(Int_t) SLICES_MFADC]; //@< array to write the fadc 434 //@< response from the database 435 Byte_t trigger_map[((Int_t)(TRIGGER_PIXELS/8))+1];//@< Pixels on when the 436 //@< camera triggers 437 427 438 float ext[iNUMWAVEBANDS] = { //@< average atmospheric extinction in each waveband 428 439 EXTWAVEBAND1, … … 432 443 EXTWAVEBAND5 433 444 }; 434 float baseline_mv[iMAXNUMPIX]; //@< The baseline (mV) caused by the NSB; to be subtracted435 //@< in order to simulate the preamps' AC coupling436 445 437 446 float qThreshold; //@< Threshold value … … 467 476 468 477 int ch, errflg = 0; //@< used by getopt 478 479 //!@' @#### Initialisation of some variables 480 //@' 481 482 for(i=0;i<iMAXNUMPIX;i++) 483 for(j=0;j<iNUMWAVEBANDS;j++) 484 nsbrate_phepns[i][j]=0.0; //@< Starlight rates initialised at 0.0 469 485 470 486 /*!@' … … 561 577 strcpy( rootname_loop, get_loop_filename() ); 562 578 strcpy( ct_filename, get_ct_filename() ); 579 strcpy( nsbpathname, get_nsb_directory() ); 563 580 564 581 // get different parameters of the simulation … … 576 593 577 594 log(SIGNATURE, 578 "%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 ",595 "%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", 579 596 "Filenames", 580 597 "In", inname, 581 598 "Stars", starfieldname, 599 "NSB database", nsbpathname, 582 600 "CT", ct_filename, 583 601 "Data", datname, … … 697 715 698 716 MMcTrig **McTrig; 699 M HeaderTrig**HeaderTrig;717 MMcTrigHeader **HeaderTrig; 700 718 701 719 if (Write_McTrig){ … … 707 725 } 708 726 709 HeaderTrig = new M HeaderTrig* [icontrigger];727 HeaderTrig = new MMcTrigHeader * [icontrigger]; 710 728 711 729 for (i=0;i<icontrigger;i++) { 712 HeaderTrig[i] = new M HeaderTrig();730 HeaderTrig[i] = new MMcTrigHeader(); 713 731 } 714 732 } … … 716 734 MFadc fadc ; //@< A instance of the Class MFadc 717 735 736 // Set the FADC pedestals for that run 737 // The values of pedestal follow a flat distribution. Some modifications 738 // mut be done to simulate a more realistic distribution of the pedestals. 739 // This simualtion is done int the SetPedestals methode inside the 740 // class MFadc 741 fadc.SetPedestals(50); 718 742 719 743 // Prepare the raw data output … … 762 786 if(!Trigger_Loop && Write_McTrig){ 763 787 764 HeaderTree.Branch("M HeaderTrig","MHeaderTrig",788 HeaderTree.Branch("MMcTrigHeader","MMcTrigHeader", 765 789 &HeaderTrig[0], bsize, split); 766 790 } 767 791 if (Trigger_Loop && Write_McTrig){ 768 for(char branchname[ 10],i=0;i<icontrigger;i++){792 for(char branchname[20],i=0;i<icontrigger;i++){ 769 793 770 794 sprintf(help,"%i",i+1); 771 strcpy (branchname, "M HeaderTrig");795 strcpy (branchname, "MMcTrigHeader"); 772 796 strcat (branchname, & help[0]); 773 797 strcat (branchname, "."); 774 HeaderTree.Branch(branchname,"M HeaderTrig",798 HeaderTree.Branch(branchname,"MMcTrigHeader", 775 799 &HeaderTrig[i], bsize, split); 776 800 } … … 787 811 } 788 812 HeaderTrig[0]->SetThreshold( fpixelthres); 789 813 HeaderTrig[0]->SetAmplitud(Trigger_response_ampl); 814 HeaderTrig[0]->SetFwhm(Trigger_response_fwhm); 815 HeaderTrig[0]->SetOverlap(Trigger_overlaping_time); 816 HeaderTrig[0]->SetGate(Trigger_gate_length); 790 817 } 791 818 if(Trigger_Loop && Write_McTrig){ … … 800 827 } 801 828 HeaderTrig[iconcount]->SetThreshold( fpixelthres); 829 HeaderTrig[iconcount]->SetAmplitud(Trigger_response_ampl); 830 HeaderTrig[iconcount]->SetFwhm(Trigger_response_fwhm); 831 HeaderTrig[iconcount]->SetOverlap(Trigger_overlaping_time); 832 HeaderTrig[iconcount]->SetGate(Trigger_gate_length); 802 833 iconcount++; 803 834 } … … 902 933 // prepare the NSB simulation 903 934 935 // Instance of the Mlons class 936 MLons lons(Trigger_response_ampl, Trigger_response_fwhm, 937 MFADC_RESPONSE_AMPLITUDE, MFADC_RESPONSE_FWHM); 938 939 lons.SetPath(nsbpathname); 940 904 941 if( simulateNSB ){ 905 942 … … 911 948 &cam, 912 949 nsbrate_phepns ); 950 float dum; 951 for(i=0; i<cam.inumpixels;i++){ 952 dum=0; 953 for(j=0;j<iNUMWAVEBANDS;j++) 954 dum+=nsbrate_phepns[i][j]; 955 cout<<"Wuschel "<<dum<<endl; 956 } 957 913 958 if (k != 0){ 914 959 cout << "Error when reading starfield... \nExiting.\n"; … … 923 968 } 924 969 970 // calculate nsb rate including diffuse and starlight 971 for(i=0; i<cam.inumpixels;i++){ 972 nsb_phepns[i]= diffnsb_phepns[i]; 973 for(j=0;j<iNUMWAVEBANDS;j++) 974 nsb_phepns[i]=nsb_phepns[i]+ nsbrate_phepns[i][j]; 975 cout<<"Huschel "<<nsb_phepns[i]<<endl; 976 } 925 977 } 926 978 … … 966 1018 967 1019 fnpix = new float [ ct_NPixels ]; 968 fnpixclean = new float [ ct_NPixels ]; 969 970 // initialize baseline 971 972 for(i=0; i<cam.inumpixels; i++){ 973 baseline_mv[i] = 0.; 974 } 975 1020 1021 976 1022 //!@' @#### Main loop. 977 1023 //@' … … 1023 1069 1024 1070 fread( (char*)&mcevth, mcevth.mysize(), 1, inputfile ); 1025 1071 1026 1072 // calculate core distance and impact parameter 1027 1073 1028 1074 coreD = mcevth.get_core(&coreX, &coreY); 1029 1075 1030 1076 // calculate impact parameter (shortest distance betwee the original 1031 1077 // trajectory of the primary (assumed shower-axis) and the … … 1102 1148 impactD = fabs(num)/den; 1103 1149 1104 // fprintf(stderr, "[%f %f,%f %f] (%f %f %f) (%f %f %f) %f/%f = ",1105 // thetashw, phishw, thetaCT, phiCT, l1, m1, n1, l2, m2, n2,1106 // num, den);1107 1108 1150 } 1109 1151 … … 1127 1169 if(simulateNSB){ 1128 1170 1129 k = produce_nsb_phes( &arrtmin_ns, // will be changed by the function! 1130 &arrtmax_ns, // will be changed by the function! 1131 thetaCT, 1132 &cam, 1133 nsbrate_phepns, 1134 diffnsb_phepns, 1135 ext, 1136 fnpix, // will be changed by the function! 1137 &Trigger, // will be changed by the function! 1138 &fadc, // will be changed by the function! 1139 &inumphe, // important for later: the size of photoe[] 1140 baseline_mv // will be generated by the function 1141 ); 1142 1143 if( k != 0 ){ // non-zero returnvalue means error 1144 cout << "Exiting.\n"; 1145 exit(1); 1146 } 1147 1171 // Fill trigger and fadc response in the trigger class from teh database 1172 for(i=0;i<cam.inumpixels;i++) 1173 if(nsb_phepns[i]>0.0){ 1174 k=lons.GetResponse(nsb_phepns[i],0.1, 1175 & nsb_trigresp[0],& nsb_fadcresp[0]); 1176 if(k==0){ 1177 cout << "Exiting.\n"; 1178 exit(1); 1179 } 1180 Trigger.SetNSB(i,nsb_trigresp); 1181 fadc.Set(i,nsb_fadcresp); 1182 } 1148 1183 }// end if(simulateNSB) ... 1149 1184 … … 1167 1202 exit(1); 1168 1203 } 1169 1204 1170 1205 log(SIGNATURE, "End of this event: %d cphs(+%d). . .\n", 1171 1206 ncph, ntcph); … … 1191 1226 } 1192 1227 1193 cout << "Total number of phes: " << inumphe <<endl; 1194 1228 cout << "Total number of phes: " << inumphe<<" + "; 1229 inumphensb=0; 1230 for (i=0;i<cam.inumpixels;i++){ 1231 inumphensb+=nsb_phepns[i]*TOTAL_TRIGGER_TIME; 1232 } 1233 cout<<inumphensb<<endl; 1195 1234 1196 1235 //++++++++++++++++++++++++++++++++++++++++++++++++++ … … 1206 1245 // TRIGGER HERE 1207 1246 1208 1209 1247 // 1210 1248 // now the noise of the electronic … … 1215 1253 1216 1254 fadc.ElecNoise() ; 1255 1256 // now a shift in the fadc signal due to the pedestlas is 1257 // intorduced 1258 // This is done inside the class MFadc by the method Pedestals 1259 fadc.Pedestals(); 1217 1260 1218 1261 // We study several trigger conditons … … 1274 1317 if (Write_McTrig) 1275 1318 McTrig[iconcount]->SetTime(Trigger.GetFirstLevelTime(ii),ii+1); 1276 if (Write_McTrig) 1277 McTrig[iconcount]->SetPixel(Trigger.GetFirstLevelPixel(ii),ii+1); 1278 1319 if (Write_McTrig){ 1320 Trigger.GetMapDiskriminator(trigger_map); 1321 McTrig[iconcount]->SetMapPixels(trigger_map,ii); 1322 } 1279 1323 // 1280 1324 // fill inside the class fadc the member output … … 1292 1336 for(i=0;i<ct_NPixels;i++){ 1293 1337 for (j=0;j<FADC_SLICES;j++){ 1294 fadcValues->AddAt( (Char_t) (fadc.GetFadcSignal(i,j)),j);1338 fadcValues->AddAt(fadc.GetFadcSignal(i,j),j); 1295 1339 } 1296 1340 EvtData[iconcount]->AddPixel(i+1000*ii,fadcValues,0); … … 1325 1369 mcevth.get_coreY(), 1326 1370 impactD, 1327 ulli, ulli,1328 (UShort_t) ncph,1329 1371 ulli, 1330 (UShort_t) ncph) ; 1331 } 1372 ulli, 1373 (UInt_t) ncph, 1374 (UInt_t) ncph, 1375 (UInt_t) inumphe, 1376 (UInt_t) inumphensb+inumphe); 1377 } 1332 1378 // Fill the Tree with the current leaves of each branch 1333 1379 i=EvtTree.Fill() ; … … 1402 1448 McTrig[0]->SetTime(Trigger.GetFirstLevelTime(ii),ii+1); 1403 1449 1404 if (Write_McTrig) 1405 McTrig[0]->SetPixel(Trigger.GetFirstLevelPixel(ii),ii+1); 1450 if (Write_McTrig){ 1451 Trigger.GetMapDiskriminator(trigger_map); 1452 McTrig[0]->SetMapPixels(trigger_map,ii); 1453 } 1406 1454 1407 1455 // Fill Evt information … … 1419 1467 for(i=0;i<ct_NPixels;i++){ 1420 1468 for (j=0;j<FADC_SLICES;j++){ 1421 fadcValues->AddAt( (Char_t) (fadc.GetFadcSignal(i,j)),j);1469 fadcValues->AddAt(fadc.GetFadcSignal(i,j),j); 1422 1470 } 1423 1471 EvtData[0]->AddPixel(i+ii*1000,fadcValues,0); … … 1437 1485 mcevth.get_coreY(), 1438 1486 impactD, 1439 ulli, ulli,1440 (UShort_t) ncph,1441 1487 ulli, 1442 (UShort_t) ncph) ; 1443 } 1488 ulli, 1489 (UInt_t) ncph, 1490 (UInt_t) ncph, 1491 (UInt_t) inumphe, 1492 (UInt_t) inumphensb+inumphe); 1493 } 1444 1494 // We don not count photons out of the camera. 1445 1495 … … 3096 3146 // 3097 3147 // $Log: not supported by cvs2svn $ 3148 // Revision 1.16 2001/01/18 18:44:40 magicsol 3149 // *** empty log message *** 3150 // 3098 3151 // Revision 1.15 2001/01/17 09:32:27 harald 3099 3152 // The changes are neccessary to have the same name for trees in MC and in … … 3119 3172 // 3120 3173 // $Log: not supported by cvs2svn $ 3174 // Revision 1.16 2001/01/18 18:44:40 magicsol 3175 // *** empty log message *** 3176 // 3121 3177 // Revision 1.15 2001/01/17 09:32:27 harald 3122 3178 // The changes are neccessary to have the same name for trees in MC and in
Note:
See TracChangeset
for help on using the changeset viewer.