Changeset 5247
- Timestamp:
- 10/12/04 14:39:34 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
r5094 r5247 21 21 // 22 22 // $RCSfile: camera.cxx,v $ 23 // $Revision: 1.7 1$23 // $Revision: 1.72 $ 24 24 // $Author: moralejo $ 25 // $Date: 2004- 09-17 09:20:52$25 // $Date: 2004-10-12 13:39:34 $ 26 26 // 27 27 //////////////////////////////////////////////////////////////////////// … … 181 181 static int FADC_Scan = FALSE; 182 182 183 //@: flag: TRUE: show all trigger si ngnal in the screen; FALSE: don't183 //@: flag: TRUE: show all trigger signal in the screen; FALSE: don't 184 184 static int Trigger_Scan = FALSE; 185 185 … … 198 198 199 199 //@: Properties of the FADC 200 static int FADC_shape = 0;200 static Int_t FADC_shape = 0; 201 201 static float FADC_response_integ = MFADC_RESPONSE_INTEGRAL; 202 202 static float FADC_response_fwhm = MFADC_RESPONSE_FWHM; 203 static int FADC_shape_out = 0;203 static Int_t FADC_shape_out = 0; 204 204 static float FADC_resp_integ_out = MFADC_RESPONSE_INTEGRAL; 205 205 static float FADC_resp_fwhm_out = MFADC_RESPONSE_FWHM; 206 static float FADC_slices_per_ns = FADC_SLICES_PER_NSEC; 207 static Int_t FADC_slices_written = FADC_SLICES; 206 208 static float FADC_noise_inner = 2.0; 207 209 static float FADC_noise_outer = 2.0; 208 static float DIGITAL_noise = 2.0;210 static float DIGITAL_noise = 0.0; 209 211 static float FADC_high2low = HIGH2LOWGAIN; 210 212 … … 411 413 Float_t nsb_trigresp[TRIGGER_TIME_SLICES]; //@< array to write the trigger 412 414 //@< response from the database 413 Float_t nsb_fadcresp[(Int_t) SLICES_MFADC];//@< array to write the fadc415 Float_t *nsb_fadcresp; //@< array to write the fadc 414 416 //@< response from the database 415 417 Byte_t trigger_map[((Int_t)(CAMERA_PIXELS/8))+1]; //@< Pixels on when the … … 674 676 get_FADC_properties 675 677 (&FADC_shape, &FADC_response_integ, &FADC_response_fwhm, 676 &FADC_shape_out, &FADC_resp_integ_out, &FADC_resp_fwhm_out); 678 &FADC_shape_out, &FADC_resp_integ_out, &FADC_resp_fwhm_out, 679 &FADC_slices_per_ns, &FADC_slices_written); 680 681 // Allocate memory for the NSB contribution to the FADC signal: 682 nsb_fadcresp = new Float_t[(Int_t)(FADC_slices_per_ns*TOTAL_TRIGGER_TIME)]; 677 683 678 684 FADC_high2low=get_High_to_Low(); … … 895 901 Int_t Lev0MT[MAX_NUMBER_OF_CTS], Lev1MT[MAX_NUMBER_OF_CTS]; 896 902 897 fadcValues = new TArrayC(FADC_ SLICES);898 fadcValuesLow = new TArrayC(FADC_ SLICES);903 fadcValues = new TArrayC(FADC_slices_written); 904 fadcValuesLow = new TArrayC(FADC_slices_written); 899 905 900 906 // number of pixels for parameters … … 988 994 FADC_shape_out, 989 995 FADC_resp_integ_out,FADC_resp_fwhm_out, 990 get_trig_delay() 991 ) ; //@< A instance of the Class MFadc 996 get_trig_delay(), 997 FADC_slices_per_ns, 998 FADC_slices_written); //@< A instance of the Class MFadc 992 999 993 1000 … … 1187 1194 RunHeader->SetRunType(256); 1188 1195 RunHeader->SetRunNumber(0); 1189 RunHeader->SetNumSamples(FADC_ SLICES, FADC_SLICES);1196 RunHeader->SetNumSamples(FADC_slices_written, FADC_slices_written); 1190 1197 RunHeader->SetNumCrates(1); 1191 1198 RunHeader->SetNumPixInCrate(ct_NPixels); … … 1255 1262 } 1256 1263 1257 HeaderFadc[0]->SetShape( FADC_shape);1258 HeaderFadc[0]->SetShapeOuter( FADC_shape_out);1264 HeaderFadc[0]->SetShape((Float_t)FADC_shape); 1265 HeaderFadc[0]->SetShapeOuter((Float_t)FADC_shape_out); 1259 1266 HeaderFadc[0]->SetAmplitud(FADC_response_integ, 1260 1267 FADC_resp_integ_out); … … 1280 1287 1281 1288 Fadc_CT[i]->GetPedestals(&fadc_pedestals[0]); 1282 HeaderFadc[i]->SetShape( FADC_shape);1283 HeaderFadc[i]->SetShapeOuter( FADC_shape_out);1289 HeaderFadc[i]->SetShape((Float_t)FADC_shape); 1290 HeaderFadc[i]->SetShapeOuter((Float_t)FADC_shape_out); 1284 1291 HeaderFadc[i]->SetAmplitud(FADC_response_integ, 1285 1292 FADC_resp_integ_out); … … 1308 1315 for(itopocount=0;itopocount<=Trigger_loop_utop-Trigger_loop_ltop;itopocount++){ 1309 1316 Fadc_CT[0]->GetPedestals(&fadc_pedestals[0]); 1310 HeaderFadc[iconcount]->SetShape( FADC_shape);1311 HeaderFadc[iconcount]->SetShapeOuter( FADC_shape_out);1317 HeaderFadc[iconcount]->SetShape((Float_t)FADC_shape); 1318 HeaderFadc[iconcount]->SetShapeOuter((Float_t)FADC_shape_out); 1312 1319 HeaderFadc[iconcount]->SetAmplitud(FADC_response_integ, 1313 1320 FADC_resp_integ_out); … … 1423 1430 } 1424 1431 1425 // prepare the NSB simulation1432 // prepare the NSB simulation 1426 1433 1427 1434 // Instance of the Mlons class 1428 MLons lons(0.0, Trigger_response_ampl, Trigger_response_fwhm, 1429 float(FADC_shape),FADC_response_integ,FADC_response_fwhm); 1430 1431 lons.SetSeed(Int_t(get_seeds(1)/get_seeds(0))+1); 1435 1436 MLons lons(0, Trigger_response_ampl, Trigger_response_fwhm, 1437 FADC_shape, FADC_response_integ, FADC_response_fwhm, 1438 FADC_slices_per_ns); 1439 1440 lons.SetSeed(Int_t(get_seeds(1)%get_seeds(0))+1); 1432 1441 1433 1442 lons.SetPath(nsbpathname); 1434 1443 1435 1444 // Instance of the Mlons class 1436 MLons lons_outer(0.0, Trigger_response_ampl, Trigger_response_fwhm, 1437 float(FADC_shape_out),FADC_resp_integ_out,FADC_resp_fwhm_out); 1438 1439 lons_outer.SetSeed(Int_t(get_seeds(1)/get_seeds(0))+2); 1445 MLons lons_outer(0, Trigger_response_ampl, Trigger_response_fwhm, 1446 FADC_shape_out,FADC_resp_integ_out,FADC_resp_fwhm_out, 1447 FADC_slices_per_ns); 1448 1449 lons_outer.SetSeed(Int_t(get_seeds(1)%get_seeds(0))+2); 1440 1450 1441 1451 lons_outer.SetPath(nsbpath_outer); 1442 1452 1443 if( simulateNSB 1453 if( simulateNSB){ 1444 1454 1445 1455 // … … 1451 1461 // Then we will have to use mirror_frac[ict] 1452 1462 // 1453 log(SIGNATURE,"Produce NSB rates from Star Field ");1463 log(SIGNATURE,"Produce NSB rates from Star Field...\n"); 1454 1464 1455 1465 k = produce_nsbrates( starfieldname, … … 1458 1468 0, 1459 1469 mirror_frac[0]); 1460 1461 1470 1462 1471 // … … 1597 1606 Fadc_CT[ict]->ElecNoise() ; 1598 1607 } 1599 if(simulateNSB){ 1600 for(UInt_t ui=0; 1601 ui<((MGeomCam*)(camgeom.UncheckedAt(ict)))->GetNumPixels(); 1602 ui++){ 1603 if(nsb_phepns[ict][ui]>0.0){ 1604 if((*((MGeomCam*)(camgeom.UncheckedAt(ict))))[ui].GetD()>(*((MGeomCam*)(camgeom.UncheckedAt(ict))))[0].GetD()){ 1605 k=lons_outer.GetResponse(nsb_phepns[ict][ui],0.01, 1606 & nsb_trigresp[0], 1607 & nsb_fadcresp[0]); 1608 if(simulateNSB) 1609 { 1610 for(UInt_t ui=0; 1611 ui<((MGeomCam*)(camgeom.UncheckedAt(ict)))->GetNumPixels(); 1612 ui++) 1613 { 1614 if(nsb_phepns[ict][ui]>0.0) 1615 { 1616 if((*((MGeomCam*)(camgeom.UncheckedAt(ict))))[ui].GetD() > 1617 (*((MGeomCam*)(camgeom.UncheckedAt(ict))))[0].GetD()) 1618 { 1619 1620 k = lons_outer.GetResponse(nsb_phepns[ict][ui],0.01, 1621 & nsb_trigresp[0], 1622 & nsb_fadcresp[0]); 1623 } 1624 else 1625 { 1626 k=lons.GetResponse(nsb_phepns[ict][ui],0.01, 1627 & nsb_trigresp[0],& nsb_fadcresp[0]); 1628 } 1629 1630 if(k==0) 1631 { 1632 cout << "Exiting.\n"; 1633 exit(1); 1634 } 1635 Fadc_CT[ict]->AddSignal(ui,nsb_fadcresp); 1636 } 1608 1637 } 1609 else{1610 k=lons.GetResponse(nsb_phepns[ict][ui],0.01,1611 & nsb_trigresp[0],& nsb_fadcresp[0]);1612 }1613 if(k==0){1614 cout << "Exiting.\n";1615 exit(1);1616 }1617 Fadc_CT[ict]->AddSignal(ui,nsb_fadcresp);1618 }1619 1638 } 1620 }1621 1639 Fadc_CT[ict]->Pedestals(); 1622 1640 … … 1669 1687 } 1670 1688 else{ 1671 1672 1689 for(int ict=0;ict<ct_Number;ict++){ 1673 1690 1674 1691 log( SIGNATURE, "Opening input \"rfl\" file %s\n", inname_CT[ict] ); 1675 1692 inputfile[ict] = fopen( inname_CT[ict], "r" ); … … 1917 1934 inumphe=(inumphe<inumphe_CT[ict])?inumphe_CT[ict]:inumphe; 1918 1935 1919 if( k != 0 ){ // non-zero return value means error1936 if( k != 0 ){ // non-zero return value means error 1920 1937 cout << "Exiting.\n"; 1921 1938 exit(1); … … 1925 1942 // NSB simulation 1926 1943 1927 if(simulateNSB && nphe2NSB<=inumphe){ 1928 1929 if(Starfield_rotate){ 1944 if(simulateNSB && nphe2NSB<=inumphe) 1945 { 1946 1947 if(Starfield_rotate){ 1930 1948 1931 // Introduction rho angle1949 // Introduction rho angle 1932 1950 1933 zenith = thetashw; 1934 azimutal = phishw; 1935 C1 = 0.48 * sin(zenith) - 0.87 * cos(zenith) * cos(azimutal); 1936 C3 = (0.87 * cos(zenith) - 0.48 * sin(zenith) * cos(azimutal)); 1937 C2 = sqrt( sin(zenith) * sin(zenith) * sin(azimutal) * sin(azimutal) + C3 * C3 ); 1938 rho = acos( C1/C2 ); 1951 zenith = thetashw; 1952 azimutal = phishw; 1953 C1 = 0.48 * sin(zenith) - 0.87 * cos(zenith) * cos(azimutal); 1954 C3 = (0.87 * cos(zenith) - 0.48 * sin(zenith) * cos(azimutal)); 1955 C2 = sqrt( sin(zenith) * sin(zenith) * sin(azimutal) * sin(azimutal) + 1956 C3 * C3 ); 1957 rho = acos( C1/C2 ); 1939 1958 1940 if ( sin(azimutal) < 0) 1941 { 1959 if ( sin(azimutal) < 0) 1942 1960 rho = 2 * 3.14159 - rho; 1943 } 1944 else 1945 { 1961 else 1946 1962 rho = rho; 1947 } 1948 rho = rho*180/3.14159; 1949 1950 // Rotation of the NSB 1951 // FIXME --- We should rotate for all cameras. Is it always the same rho? 1952 for(int ict=0;ict<ct_Number;ict++){ 1953 k = size_rotated( 1954 &nsb_phepns_rotated[ict][0], 1955 nsb_phepns[ict], 1956 rho); 1963 1964 rho = rho*180/3.14159; 1965 1966 // Rotation of the NSB 1967 // FIXME --- We should rotate for all cameras. Is it always the same rho? 1968 for(int ict=0;ict<ct_Number;ict++) 1969 k = size_rotated(&nsb_phepns_rotated[ict][0], 1970 nsb_phepns[ict], 1971 rho); 1972 } 1973 1974 // Fill trigger and fadc response in the trigger class from the database 1975 for(int ict=0;ict<ct_Number;ict++) 1976 { 1977 for(UInt_t ui=0; 1978 ui<((MGeomCam*)(camgeom.UncheckedAt(ict)))->GetNumPixels(); 1979 ui++) 1980 { 1981 if(nsb_phepns_rotated[ict][ui]>0.0) 1982 { 1983 if((*((MGeomCam*)(camgeom.UncheckedAt(ict))))[ui].GetD() > 1984 (*((MGeomCam*)(camgeom.UncheckedAt(ict))))[0].GetD()) 1985 { 1986 k=lons_outer.GetResponse(nsb_phepns_rotated[ict][ui],0.01, 1987 & nsb_trigresp[0], 1988 & nsb_fadcresp[0]); 1989 } 1990 else 1991 { 1992 k=lons.GetResponse(nsb_phepns_rotated[ict][ui],0.01, 1993 & nsb_trigresp[0],& nsb_fadcresp[0]); 1994 } 1995 if(k==0) 1996 { 1997 cout << "Exiting.\n"; 1998 exit(1); 1999 } 2000 Trigger_CT[ict]->AddNSB(ui,nsb_trigresp); 2001 Fadc_CT[ict]->AddSignal(ui,nsb_fadcresp); 2002 } 2003 } 2004 } 2005 2006 }// end if(simulateNSB && nphe2NSB<=inumphe_CT[0]) ... 2007 2008 2009 for(int ict=0;ict<ct_Number;ict++) 2010 { 2011 inumphensb[ict]=0; 2012 2013 for (UInt_t ui=0; 2014 ui < ((MGeomCam*)(camgeom.UncheckedAt(ict)))->GetNumPixels(); 2015 ui++) 2016 inumphensb[ict]+=nsb_phepns[ict][ui]*TOTAL_TRIGGER_TIME; 2017 2018 ntcph[ict]+=ncph[ict]; 2019 if ((nshow+ntshow+1)%100 == 1){ 2020 log(SIGNATURE, "End of this event: %d cphs(+%d). . .\n", 2021 ncph[ict], ntcph[ict]); 2022 2023 cout << "Total number of phes in CT "<<ict<<": " 2024 << inumphe_CT[ict]<<" (+ "; 2025 cout<<inumphensb[ict]<<" mean expected number from NSB)"<<endl; 1957 2026 } 1958 2027 } 1959 1960 // Fill trigger and fadc response in the trigger class from the database1961 for(int ict=0;ict<ct_Number;ict++){1962 1963 for(UInt_t ui=0;ui<((MGeomCam*)(camgeom.UncheckedAt(ict)))->GetNumPixels();ui++){1964 if(nsb_phepns_rotated[ict][ui]>0.0){1965 if((*((MGeomCam*)(camgeom.UncheckedAt(ict))))[ui].GetD()>(*((MGeomCam*)(camgeom.UncheckedAt(ict))))[0].GetD()){1966 k=lons_outer.GetResponse(nsb_phepns_rotated[ict][ui],0.01,1967 & nsb_trigresp[0],1968 & nsb_fadcresp[0]);1969 }1970 else{1971 k=lons.GetResponse(nsb_phepns_rotated[ict][ui],0.01,1972 & nsb_trigresp[0],& nsb_fadcresp[0]);1973 }1974 if(k==0){1975 cout << "Exiting.\n";1976 exit(1);1977 }1978 Trigger_CT[ict]->AddNSB(ui,nsb_trigresp);1979 Fadc_CT[ict]->AddSignal(ui,nsb_fadcresp);1980 }1981 }1982 }1983 1984 }// end if(simulateNSB && nphe2NSB<=inumphe_CT[0]) ...1985 1986 for(int ict=0;ict<ct_Number;ict++){1987 inumphensb[ict]=0;1988 for (UInt_t ui=0;ui<1989 ((MGeomCam*)(camgeom.UncheckedAt(ict)))->GetNumPixels();ui++){1990 inumphensb[ict]+=nsb_phepns[ict][ui]*TOTAL_TRIGGER_TIME;1991 }1992 ntcph[ict]+=ncph[ict];1993 if ((nshow+ntshow+1)%100 == 1){1994 log(SIGNATURE, "End of this event: %d cphs(+%d). . .\n",1995 ncph[ict], ntcph[ict]);1996 1997 cout << "Total number of phes in CT "<<ict<<": "1998 << inumphe_CT[ict]<<" (+ ";1999 cout<<inumphensb[ict]<<" mean expected number from NSB)"<<endl;2000 }2001 }2002 2028 2003 2029 // skip it ? … … 2033 2059 2034 2060 // We should simulate the AC coupling behaviour: 2035 // For the FADC it is only done for the NSB while producin r2061 // For the FADC it is only done for the NSB while producing 2036 2062 // the StarResponse database. 2037 2063 // For the trigger is done in the Trigger.Diskriminate(), which 2038 // is called later (it should be sep erated to speed up the program2064 // is called later (it should be separated to speed up the program) 2039 2065 // 2040 2066 … … 2044 2070 // 2045 2071 2046 for(int ict=0;ict<ct_Number;ict++) { 2047 if (addElecNoise && nphe2NSB<=inumphe){ 2048 2049 Trigger_CT[ict]->ElecNoise(Trigger_noise) ; 2050 2051 Fadc_CT[ict]->ElecNoise() ; 2072 for(int ict=0;ict<ct_Number;ict++) 2073 { 2074 if (addElecNoise && nphe2NSB<=inumphe) 2075 { 2076 Trigger_CT[ict]->ElecNoise(Trigger_noise) ; 2077 Fadc_CT[ict]->ElecNoise() ; 2078 } 2052 2079 } 2053 }2054 2080 2055 // now a shift in the fadc signal due to the pedest las is2056 // int orduced2081 // now a shift in the fadc signal due to the pedestals is 2082 // introduced 2057 2083 // This is done inside the class MFadc by the method Pedestals 2058 for(int ict=0;ict<ct_Number;ict++) { 2084 2085 for(int ict=0;ict<ct_Number;ict++) 2059 2086 Fadc_CT[ict]->Pedestals(); 2060 } 2087 2061 2088 2062 2089 // We study several trigger conditons 2063 if(Trigger_Loop){ 2064 2065 // Set to zero the flag to know if some conditon has triggered 2066 btrigger=0; 2067 flagstoring = 0; 2068 2069 // Loop over trigger threshold 2070 int iconcount; 2071 for (iconcount=0, ithrescount=0, fthrescount=Trigger_loop_lthres;fthrescount<=Trigger_loop_uthres;ithrescount++, fthrescount+=Trigger_loop_sthres){ 2072 for (int i=0;i<ct_NPixels;i++){ 2073 fpixelthres[i]= 2074 ((Float_t)(fthrescount)>=qThreshold[0][i])? 2075 (Float_t)(fthrescount):qThreshold[0][i]; 2076 2077 // Rise the discrimnator threshold to avoid huge rates 2078 2079 if(riseDiskThres>0.0 && simulateNSB && nphe2NSB<=inumphe) 2080 for(int ii=0;ii<ct_NPixels;ii++) 2081 if( nsb_phepns_rotated[0][ii]>riseDiskThres) 2082 fpixelthres[ii]=secureDiskThres; 2083 } 2084 Trigger_CT[0]->SetThreshold(fpixelthres); 2090 if(Trigger_Loop) 2091 { 2092 // Set to zero the flag to know if some conditon has triggered 2093 btrigger=0; 2094 flagstoring = 0; 2095 2096 // Loop over trigger threshold 2097 int iconcount; 2098 for (iconcount=0, ithrescount=0, fthrescount=Trigger_loop_lthres; 2099 fthrescount <= Trigger_loop_uthres; 2100 ithrescount++, fthrescount += Trigger_loop_sthres) 2101 { 2102 for (int i=0;i<ct_NPixels;i++) 2103 { 2104 fpixelthres[i] = 2105 ((Float_t)(fthrescount)>=qThreshold[0][i])? 2106 (Float_t)(fthrescount):qThreshold[0][i]; 2107 2108 // Rise the discrimnator threshold to avoid huge rates 2109 2110 if(riseDiskThres>0.0 && simulateNSB && nphe2NSB<=inumphe) 2111 for(int ii=0;ii<ct_NPixels;ii++) 2112 if( nsb_phepns_rotated[0][ii]>riseDiskThres) 2113 fpixelthres[ii]=secureDiskThres; 2114 } 2115 Trigger_CT[0]->SetThreshold(fpixelthres); 2085 2116 2086 Trigger_CT[0]->Diskriminate(); 2087 2117 Trigger_CT[0]->Diskriminate(); 2118 2119 // 2120 // look if in all the signals in the trigger signal branch 2121 // is a possible Trigger. Therefore we habe to diskriminate all 2122 // the simulated analog signals (Method Diskriminate in class 2123 // MTrigger). We look simultanously for the moments at which 2124 // there are more than TRIGGER_MULTI pixels above the 2125 // CHANNEL_THRESHOLD. 2126 // 2088 2127 2089 // 2090 // look if in all the signals in the trigger signal branch 2091 // is a possible Trigger. Therefore we habe to diskriminate all 2092 // the simulated analog signals (Method Diskriminate in class 2093 // MTrigger). We look simultanously for the moments at which 2094 // there are more than TRIGGER_MULTI pixels above the 2095 // CHANNEL_THRESHOLD. 2096 // 2128 // Set trigger flags to zero 2129 Lev0=0; 2130 Lev1=0; 2131 2132 // loop over multiplicity of trigger configuration 2133 for (imulticount = Trigger_loop_lmult; 2134 imulticount <= Trigger_loop_umult; 2135 imulticount++) 2136 { 2137 Trigger_CT[0]->SetMultiplicity(imulticount); 2138 Trigger_CT[0]->ClearZero(); 2139 2140 Lev0=(Short_t) Trigger_CT[0]->ZeroLevel(); 2141 if (Lev0>0 || Write_All_Images || btrigger) 2142 { 2143 2144 // loop over topologies 2145 for(itopocount=Trigger_loop_ltop; 2146 itopocount<=Trigger_loop_utop; 2147 itopocount++) 2148 { 2149 Lev1=0; 2150 2151 if(itopocount==0 && imulticount>7) 2152 continue; 2153 2154 //COBB if(itopocount==2 && imulticount<3) continue; 2155 // It only makes to look for a different topology 2156 // if there are 3 or more N pixels. 2157 if(imulticount<3) 2158 Trigger_CT[0]->SetTopology(1); 2159 else 2160 { 2161 // We should be careful that topologies are sort from 2162 // the less to the more restrictive one. 2163 Trigger_CT[0]->SetTopology(isorttopo[itopocount]); 2164 } 2165 Trigger_CT[0]->ClearFirst(); 2166 2167 // 2168 // Start the First Level Trigger simulation 2169 // 2170 if(Lev0!=0) 2171 Lev1=Trigger_CT[0]->FirstLevel(); 2172 if(Lev1>0) { 2173 btrigger= 1; 2174 ntriggerloop[ithrescount] 2175 [imulticount-Trigger_loop_lmult] 2176 [itopocount-Trigger_loop_ltop]++; 2177 } 2178 2179 Lev0=1; 2180 Int_t NumImages = Lev1; 2181 if(Lev1==0 && (Write_All_Images || btrigger)) 2182 { 2183 btrigger= 1; 2184 NumImages=1; 2185 Lev0=0; 2186 } 2187 2188 for (Int_t ii=0;ii<NumImages;ii++) 2189 { 2190 if (Write_McTrig) 2191 { 2192 McTrig[iconcount]->SetFirstLevel ((ii+1)*Lev0); 2193 McTrig[iconcount]-> 2194 SetTime(Trigger_CT[0]->GetFirstLevelTime(ii),ii+1); 2195 Trigger_CT[0]->GetMapDiskriminator(trigger_map); 2196 McTrig[iconcount]->SetMapPixels(trigger_map,ii); 2197 } 2198 // 2199 // fill inside the class fadc the member output 2200 // 2201 2202 Fadc_CT[0]->TriggeredFadc(Trigger_CT[0]-> 2203 GetFirstLevelTime(ii)); 2097 2204 2098 // Set trigger flags to zero 2099 Lev0=0; 2100 Lev1=0; 2101 2102 // loop over multiplicity of trigger configuration 2103 for (imulticount=Trigger_loop_lmult;imulticount<=Trigger_loop_umult;imulticount++){ 2104 Trigger_CT[0]->SetMultiplicity(imulticount); 2105 Trigger_CT[0]->ClearZero(); 2106 2107 Lev0=(Short_t) Trigger_CT[0]->ZeroLevel(); 2108 if (Lev0>0 || Write_All_Images || btrigger){ 2109 2110 // loop over topologies 2111 for(itopocount=Trigger_loop_ltop;itopocount<=Trigger_loop_utop;itopocount++){ 2112 Lev1=0; 2113 2114 if(itopocount==0 && imulticount>7) continue; 2115 //COBB if(itopocount==2 && imulticount<3) continue; 2116 // It only makes to look for a different topology 2117 // if there are 3 or more N pixels. 2118 if(imulticount<3) 2119 Trigger_CT[0]->SetTopology(1); 2120 else 2121 { 2122 // We should be careful that topologies are sort from 2123 // the less to the more restrictive one. 2124 Trigger_CT[0]->SetTopology(isorttopo[itopocount]); 2125 } 2126 Trigger_CT[0]->ClearFirst(); 2127 2128 // 2129 // Start the First Level Trigger simulation 2130 // 2131 if(Lev0!=0) 2132 Lev1=Trigger_CT[0]->FirstLevel(); 2133 if(Lev1>0) { 2134 btrigger= 1; 2135 ntriggerloop[ithrescount][imulticount-Trigger_loop_lmult][itopocount-Trigger_loop_ltop]++; 2136 } 2137 2138 Lev0=1; 2139 Int_t NumImages = Lev1; 2140 if(Lev1==0 && (Write_All_Images || btrigger)){ 2141 btrigger= 1; 2142 NumImages=1; 2143 Lev0=0; 2144 } 2145 2146 for (Int_t ii=0;ii<NumImages;ii++){ 2147 if (Write_McTrig){ 2148 McTrig[iconcount]->SetFirstLevel ((ii+1)*Lev0); 2149 McTrig[iconcount]->SetTime(Trigger_CT[0]->GetFirstLevelTime(ii),ii+1); 2150 Trigger_CT[0]->GetMapDiskriminator(trigger_map); 2151 McTrig[iconcount]->SetMapPixels(trigger_map,ii); 2205 if( Write_RawEvt ) 2206 { 2207 // 2208 // Fill the header of this event 2209 // 2210 2211 EvtHeader[iconcount]-> 2212 FillHeader( (UInt_t) (ntshow + nshow),0); 2213 2214 // fill pixel information 2215 if (Lev1 || Write_All_Images){ 2216 if (addElecNoise) Fadc_CT[0]->DigitalNoise(); 2217 for(UInt_t i=0; 2218 i<((MGeomCam*)(camgeom.UncheckedAt(0))) 2219 ->GetNumPixels();i++){ 2220 // 2221 // AM 15 01 2004: commented out "continue" 2222 // statement, so that also pixels with no 2223 // C-photons will be written to the output 2224 // in case the camera is run with no noise. 2225 // if(!Fadc_CT[0]->IsPixelUsed(i)) continue; 2226 2227 for (j=0;j<FADC_slices_written;j++){ 2228 fadcValues->AddAt(Fadc_CT[0]-> 2229 GetFadcSignal(i,j),j); 2230 fadcValuesLow->AddAt(Fadc_CT[0]-> 2231 GetFadcLowGainSignal(i,j),j); 2232 } 2233 EvtData[iconcount]->AddPixel(i,fadcValues,0); 2234 EvtData[iconcount]->AddPixel(i,fadcValuesLow,kTRUE); 2235 } 2236 } 2237 } 2238 } 2239 // 2240 // Increase counter of analised trigger conditions 2241 // 2242 iconcount++; 2243 } 2152 2244 } 2153 // 2154 // fill inside the class fadc the member output 2155 // 2156 2157 Fadc_CT[0]->TriggeredFadc(Trigger_CT[0]->GetFirstLevelTime(ii)); 2158 2159 if( Write_RawEvt ){ 2160 // 2161 // Fill the header of this event 2162 // 2163 2164 EvtHeader[iconcount]->FillHeader ( (UInt_t) (ntshow + nshow),0); 2165 // fill pixel information 2166 if (Lev1 || Write_All_Images){ 2167 if (addElecNoise) Fadc_CT[0]->DigitalNoise(); 2168 for(UInt_t i=0; 2169 i<((MGeomCam*)(camgeom.UncheckedAt(0))) 2170 ->GetNumPixels();i++){ 2171 // 2172 // AM 15 01 2004: commented out "continue" statement, so that also pixels 2173 // with no C-photons will be written to the output in case the camera 2174 // is run with no noise. 2175 // if(!Fadc_CT[0]->IsPixelUsed(i)) continue; 2176 // 2177 for (j=0;j<FADC_SLICES;j++){ 2178 fadcValues->AddAt(Fadc_CT[0]->GetFadcSignal(i,j),j); 2179 fadcValuesLow->AddAt(Fadc_CT[0]->GetFadcLowGainSignal(i,j),j); 2180 } 2181 EvtData[iconcount]->AddPixel(i,fadcValues,0); 2182 EvtData[iconcount]->AddPixel(i,fadcValuesLow,kTRUE); 2183 } 2184 } 2245 else{ 2246 break; 2185 2247 } 2186 2248 } 2187 // 2188 // Increase counter of analised trigger conditions 2189 // 2190 iconcount++; 2249 if (!btrigger) break; 2250 } 2251 if (btrigger){ 2252 2253 // 2254 // fill the MMcEvt with all information 2255 // 2256 2257 if(!flagstoring) 2258 nstoredevents++; 2259 flagstoring = 1; 2260 2261 if (Write_McEvt) { 2262 Float_t ftime, ltime; 2263 if (reflector_file_version<6){ 2264 mcevth[0].get_times(&ftime, <ime); 2265 McEvt[0]->Fill( 0, 2266 (UShort_t) mcevth[0].get_primary() , 2267 mcevth[0].get_energy(), 2268 -1.0, 2269 -1.0, 2270 -1.0, 2271 mcevth[0].get_theta(), 2272 mcevth[0].get_phi(), 2273 mcevth[0].get_core(), 2274 coreX, 2275 coreY, 2276 impactD[0], 2277 phiCT[0], 2278 thetaCT[0], 2279 ftime, 2280 ltime, 2281 0, 2282 0, 2283 0, 2284 0, 2285 0, 2286 0, 2287 0, 2288 (UInt_t)mcevth[0].get_CORSIKA(), 2289 (UInt_t)mcevth[0].get_AtmAbs(), 2290 (UInt_t)(mcevth[0].get_MirrAbs()+ 2291 mcevth[0].get_OutOfMirr()+ 2292 mcevth[0].get_BlackSpot()), 2293 (UInt_t) ncph[0], 2294 (UInt_t) inumphe_CT[0], 2295 (UInt_t) inumphensb[0]+inumphe_CT[0], 2296 -1.0, 2297 -1.0, 2298 -1.0); 2299 } 2300 else{ 2301 Float_t Nmax, t0, tmax, a, b, c, chi2; 2302 mcevth_2[0].get_times(&ftime, <ime); 2303 chi2=mcevth_2[0].get_NKGfit(&Nmax, &t0, &tmax, &a, &b, &c); 2304 McEvt[0]->Fill((UInt_t) mcevth_2[0].get_evt_number(), 2305 (UShort_t) mcevth_2[0].get_primary() , 2306 mcevth_2[0].get_energy(), 2307 mcevth_2[0].get_thick0(), 2308 mcevth_2[0].get_first_target(), 2309 mcevth_2[0].get_z_first_int(), 2310 mcevth_2[0].get_theta(), 2311 mcevth_2[0].get_phi(), 2312 mcevth_2[0].get_core(), 2313 coreX, 2314 coreY, 2315 impactD[0], 2316 mcevth_2[0].get_phi_CT(), 2317 mcevth_2[0].get_theta_CT(), 2318 ftime, 2319 ltime, 2320 Nmax, 2321 t0, 2322 tmax, 2323 a, 2324 b, 2325 c, 2326 chi2, 2327 (UInt_t)mcevth_2[0].get_CORSIKA(), 2328 (UInt_t)mcevth_2[0].get_AtmAbs(), 2329 (UInt_t)(mcevth_2[0].get_MirrAbs()+ 2330 mcevth_2[0].get_OutOfMirr()+ 2331 mcevth_2[0].get_BlackSpot()), 2332 (UInt_t) ncph[0], 2333 (UInt_t) inumphe_CT[0], 2334 (UInt_t) inumphensb[0]+inumphe_CT[0], 2335 mcevth_2[0].get_ElecFraction(), 2336 mcevth_2[0].get_MuonFraction(), 2337 mcevth_2[0].get_OtherFraction()); 2191 2338 } 2192 2339 } 2193 else{ 2194 break; 2340 // Fill the Tree with the current leaves of each branch 2341 i=EvtTree.Fill() ; 2342 2343 // Clear the branches 2344 if(Write_McTrig){ 2345 for(int i=0;i<numberBranches;i++){ 2346 McTrig[i]->Clear() ; 2347 } 2195 2348 } 2349 if( Write_RawEvt ){ 2350 for(int i=0;i<numberBranches;i++){ 2351 EvtHeader[i]->Clear() ; 2352 EvtData[i]->ResetPixels (0, 0); 2353 } 2354 } 2355 if (Write_McEvt) 2356 McEvt[0]->Clear() ; 2196 2357 } 2197 if (!btrigger) break;2198 2358 } 2199 if (btrigger){ 2200 2201 // 2202 // fill the MMcEvt with all information 2203 // 2204 2205 if(!flagstoring) 2206 nstoredevents++; 2207 flagstoring = 1; 2208 2209 if (Write_McEvt) { 2210 Float_t ftime, ltime; 2211 if (reflector_file_version<6){ 2212 mcevth[0].get_times(&ftime, <ime); 2213 McEvt[0]->Fill( 0, 2214 (UShort_t) mcevth[0].get_primary() , 2215 mcevth[0].get_energy(), 2216 -1.0, 2217 -1.0, 2218 -1.0, 2219 mcevth[0].get_theta(), 2220 mcevth[0].get_phi(), 2221 mcevth[0].get_core(), 2222 coreX, 2223 coreY, 2224 impactD[0], 2225 phiCT[0], 2226 thetaCT[0], 2227 ftime, 2228 ltime, 2229 0, 2230 0, 2231 0, 2232 0, 2233 0, 2234 0, 2235 0, 2236 (UInt_t)mcevth[0].get_CORSIKA(), 2237 (UInt_t)mcevth[0].get_AtmAbs(), 2238 (UInt_t)(mcevth[0].get_MirrAbs()+mcevth[0].get_OutOfMirr()+mcevth[0].get_BlackSpot()), 2239 (UInt_t) ncph[0], 2240 (UInt_t) inumphe_CT[0], 2241 (UInt_t) inumphensb[0]+inumphe_CT[0], 2242 -1.0, 2243 -1.0, 2244 -1.0); 2245 } 2246 else{ 2247 Float_t Nmax, t0, tmax, a, b, c, chi2; 2248 mcevth_2[0].get_times(&ftime, <ime); 2249 chi2=mcevth_2[0].get_NKGfit(&Nmax, &t0, &tmax, &a, &b, &c); 2250 McEvt[0]->Fill((UInt_t) mcevth_2[0].get_evt_number(), 2251 (UShort_t) mcevth_2[0].get_primary() , 2252 mcevth_2[0].get_energy(), 2253 mcevth_2[0].get_thick0(), 2254 mcevth_2[0].get_first_target(), 2255 mcevth_2[0].get_z_first_int(), 2256 mcevth_2[0].get_theta(), 2257 mcevth_2[0].get_phi(), 2258 mcevth_2[0].get_core(), 2259 coreX, 2260 coreY, 2261 impactD[0], 2262 mcevth_2[0].get_phi_CT(), 2263 mcevth_2[0].get_theta_CT(), 2264 ftime, 2265 ltime, 2266 Nmax, 2267 t0, 2268 tmax, 2269 a, 2270 b, 2271 c, 2272 chi2, 2273 (UInt_t)mcevth_2[0].get_CORSIKA(), 2274 (UInt_t)mcevth_2[0].get_AtmAbs(), 2275 (UInt_t)(mcevth_2[0].get_MirrAbs()+mcevth_2[0].get_OutOfMirr()+mcevth_2[0].get_BlackSpot()), 2276 (UInt_t) ncph[0], 2277 (UInt_t) inumphe_CT[0], 2278 (UInt_t) inumphensb[0]+inumphe_CT[0], 2279 mcevth_2[0].get_ElecFraction(), 2280 mcevth_2[0].get_MuonFraction(), 2281 mcevth_2[0].get_OtherFraction()); 2282 } 2283 } 2284 // Fill the Tree with the current leaves of each branch 2285 i=EvtTree.Fill() ; 2286 2287 // Clear the branches 2288 if(Write_McTrig){ 2289 for(int i=0;i<numberBranches;i++){ 2290 McTrig[i]->Clear() ; 2291 } 2292 } 2293 if( Write_RawEvt ){ 2294 for(int i=0;i<numberBranches;i++){ 2295 EvtHeader[i]->Clear() ; 2296 EvtData[i]->ResetPixels (0, 0); 2297 } 2298 } 2299 if (Write_McEvt) 2300 McEvt[0]->Clear() ; 2301 } 2302 } 2359 2303 2360 // We study a single trigger condition 2304 2361 else { 2305 2362 2306 2363 // Set to zero the flag to know if some conditon has triggered 2307 2364 btrigger=0; 2308 2365 flagstoring = 0; 2309 2366 2310 for(int ict=0;ict<ct_Number;ict++){ 2311 2312 // Setting trigger conditions 2313 Trigger_CT[ict]->SetMultiplicity(Trigger_multiplicity[ict]); 2314 Trigger_CT[ict]->SetTopology(Trigger_topology[ict]); 2315 for (int i=0;i<ct_NPixels;i++) 2316 fpixelthres[i]=qThreshold[ict][i]; 2317 2318 // Rise the discrimnator threshold to avoid huge rates 2319 if(riseDiskThres>0.0 && simulateNSB && nphe2NSB<=inumphe) 2320 for(int ii=0;ii<ct_NPixels;ii++){ 2321 if( nsb_phepns_rotated[ict][ii]>riseDiskThres) 2322 fpixelthres[ii]=secureDiskThres; 2323 } 2367 for(int ict = 0; ict < ct_Number; ict++) 2368 { 2369 2370 // Setting trigger conditions 2371 Trigger_CT[ict]->SetMultiplicity(Trigger_multiplicity[ict]); 2372 Trigger_CT[ict]->SetTopology(Trigger_topology[ict]); 2373 for (int i=0;i<ct_NPixels;i++) 2374 fpixelthres[i]=qThreshold[ict][i]; 2375 2376 // Rise the discrimnator threshold to avoid huge rates 2377 if(riseDiskThres>0.0 && simulateNSB && nphe2NSB<=inumphe) 2378 for(int ii=0;ii<ct_NPixels;ii++) 2379 { 2380 if( nsb_phepns_rotated[ict][ii]>riseDiskThres) 2381 fpixelthres[ii]=secureDiskThres; 2382 } 2324 2383 2325 Trigger_CT[ict]->SetThreshold(fpixelthres);2384 Trigger_CT[ict]->SetThreshold(fpixelthres); 2326 2385 2327 Trigger_CT[ict]->Diskriminate() ;2328 2329 //2330 // look if in all the signals in the trigger signal branch2331 // is a possible Trigger. Therefore we habe to diskriminate all2332 // the simulated analog signals (Method Diskriminate in class2333 // MTrigger). We look simultanously for the moments at which2334 // there are more than TRIGGER_MULTI pixels above the2335 // CHANNEL_THRESHOLD.2336 //2386 Trigger_CT[ict]->Diskriminate() ; 2387 2388 // 2389 // Look if in all the signals in the trigger signal branch 2390 // is a possible Trigger. Therefore we have to discriminate all 2391 // the simulated analog signals (Method Diskriminate in class 2392 // MTrigger). We look simultaneously for the moments at which 2393 // there are more than TRIGGER_MULTI pixels above the 2394 // CHANNEL_THRESHOLD. 2395 // 2337 2396 2338 2397 Lev0MT[ict] = (Short_t) Trigger_CT[ict]->ZeroLevel() ; … … 2344 2403 // 2345 2404 2346 if ( Lev0MT[ict] > 0 || Write_All_Images) { 2347 2405 if ( Lev0MT[ict] > 0 || Write_All_Images) 2348 2406 Lev1MT[ict]= Trigger_CT[ict]->FirstLevel(); 2349 } 2350 if (Lev1MT[ict]>0) {2407 2408 if (Lev1MT[ict]>0) 2351 2409 ++ntrigger[ict]; 2352 } 2410 2353 2411 } 2354 2412 2355 2413 Int_t NumImages = 0; 2356 2414 Int_t CT_triggered=0; 2357 for(int ict=0;ict<ct_Number;ict++){ 2358 if(NumImages==0 && Lev1MT[ict]>0) 2359 CT_triggered=ict; 2360 NumImages = (NumImages>=Lev1MT[ict])?NumImages:1; 2361 Lev0MT[ict]=1; 2362 if (Lev1MT[ict]==0 && Write_All_Images){ 2363 NumImages=1; 2364 Lev0MT[ict]=0; 2415 for(int ict=0;ict<ct_Number;ict++) 2416 { 2417 if(NumImages==0 && Lev1MT[ict]>0) 2418 CT_triggered=ict; 2419 NumImages = (NumImages>=Lev1MT[ict]) ? NumImages : 1; 2420 Lev0MT[ict]=1; 2421 2422 if (Lev1MT[ict]==0 && Write_All_Images) 2423 { 2424 NumImages=1; 2425 Lev0MT[ict]=0; 2426 } 2365 2427 } 2366 }2367 2428 2368 2429 for(int ict=0;ict<ct_Number;ict++){ … … 2419 2480 // if(!Fadc_CT[ict]->IsPixelUsed(i)) continue; 2420 2481 // 2421 for (j=0;j<FADC_SLICES;j++){ 2422 fadcValues->AddAt(Fadc_CT[ict]->GetFadcSignal(i,j),j); 2423 fadcValuesLow->AddAt(Fadc_CT[ict]->GetFadcLowGainSignal(i,j),j); 2424 } 2482 for (j = 0; j < FADC_slices_written; j++) 2483 { 2484 fadcValues->AddAt(Fadc_CT[ict]->GetFadcSignal(i,j),j); 2485 fadcValuesLow->AddAt(Fadc_CT[ict]->GetFadcLowGainSignal(i,j),j); 2486 } 2425 2487 EvtData[ict]->AddPixel(i,fadcValues,0); 2426 2488 EvtData[ict]->AddPixel(i,fadcValuesLow,kTRUE); … … 3929 3991 // reset variables 3930 3992 3931 for ( i=0; i<camgeom->GetNumPixels(); ++i ){ 3932 3993 for ( i=0; i<camgeom->GetNumPixels(); ++i ) 3933 3994 nphe[i] = 0.0; 3934 3935 } 3995 3936 3996 3937 3997 *itotnphe = 0; … … 4171 4231 4172 4232 4173 // open input file 4174 4175 log(SIGNATURE, "Opening starfield input \"rfl\" file %s\n", iname ); 4176 4177 infile = fopen( iname, "r" ); 4178 4179 // check if the starfield input file exists 4180 4181 if ( infile == NULL ) { 4182 4183 log( SIGNATURE, "Cannot open starfield input file: %s\n", iname ); 4184 4185 log( SIGNATURE, "There is not NSB from the Stars\n"); 4186 4187 return (0); 4188 } 4233 if (strlen(iname) == 0) 4234 { 4235 log( SIGNATURE, "No starfield input file has been provided.\n"); 4236 return (0); 4237 } 4238 else // check if the starfield input file exists and open it 4239 { 4240 log(SIGNATURE, "Opening starfield input \"rfl\" file %s\n", iname ); 4241 infile = fopen( iname, "r" ); 4242 4243 if ( infile == NULL ) 4244 { 4245 log( SIGNATURE, "ERROR! Cannot open starfield input file: %s\n", iname ); 4246 exit(-1); 4247 } 4248 } 4249 4189 4250 4190 4251 // get signature, and check it … … 4211 4272 FADC_shape_out, 4212 4273 FADC_resp_integ_out,FADC_resp_fwhm_out, 4213 get_trig_delay()); 4274 get_trig_delay(), 4275 FADC_slices_per_ns, 4276 FADC_slices_written); 4214 4277 4215 4278 // initialize flag … … 4363 4426 // 4364 4427 // $Log: not supported by cvs2svn $ 4428 // Revision 1.71 2004/09/17 09:20:52 moralejo 4429 // 4430 // Updated some calls to current version of Mars: 4431 // 4432 // - EvtData[i]->InitRead(RunHeader) instead of EvtData[i]->Init(RunHeader); 4433 // - MRawRunHeader::kMagicNumber instead of just kMagicNumber 4434 // - EvtData[i]->ResetPixels (0, 0) instead of EvtData[i]->DeletePixels(); 4435 // 4365 4436 // Revision 1.70 2004/09/16 15:23:12 moralejo 4366 4437 // … … 4524 4595 // A small back has been solved. Before, while not using the option 4525 4596 // writte_all_images, not all triggered showers were stored. Now it is solved. 4526 // For that it is importa tn taht the less restrictive trigger option is4597 // For that it is important that the less restrictive trigger option is 4527 4598 // checked first. 4528 4599 // A new facility has been introduced and now one can choose the step size in
Note:
See TracChangeset
for help on using the changeset viewer.