Changeset 5248 for trunk/MagicSoft/Simulation/Detector/StarResponse
- Timestamp:
- 10/12/04 14:43:18 (20 years ago)
- Location:
- trunk/MagicSoft/Simulation/Detector/StarResponse
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/StarResponse/MStarLight.cxx
r5099 r5248 3 3 using namespace std; 4 4 5 MStarLight::MStarLight( ) {5 MStarLight::MStarLight(Float_t fadc_slices_per_ns, Int_t response_slices_fadc) { 6 6 // 7 7 // default constructor 8 8 // 9 9 10 fBrightness = 0.; 11 fTimeRange = TIMERANGE; 12 13 fFadcSlicesPerNanosec = fadc_slices_per_ns; // "real" number of FADC slices per ns 14 15 fResponseSlicesFadc = response_slices_fadc; 16 // total number of bins in the histogram containing the response of the FADC to a 17 // single photoelectron. The bins are narrower than the true FADC slices by a factor 18 // equal to SUBBINS (see MFadcDefine.h) 19 20 21 fBinsTrig = (Int_t)(TRIG_SLICES_PER_NSEC*TIMERANGE); // Default value 4*10000=40000 22 fTrigShape = 0; 23 fAmplTrig = 0.; 24 fFwhmTrig = 0.; 25 26 fBinsFadc = (Int_t)(fFadcSlicesPerNanosec*TIMERANGE); // Default value 0.3*10000=3000 27 fFadcShape = 0; 28 fIntegFadc = 0.; 29 fFwhmFadc = 0.; 30 31 32 fTrig = new Float_t[fBinsTrig]; 33 fTrigResp = new Float_t[RESPONSE_SLICES_TRIG]; 34 fFadc = new Float_t[fBinsFadc]; 35 fFadcResp = new Float_t[fResponseSlicesFadc]; 36 37 for (Int_t i= 0; i< fBinsTrig ; i++) 38 fTrig[i] = 0. ; 39 40 for (Int_t i= 0; i < fBinsFadc; i++) 41 fFadc[i] = 0.; 42 43 for (Int_t i = 0; i < RESPONSE_SLICES_TRIG; i++) 44 fTrigResp[i] = 0.; 45 46 for (Int_t i = 0; i < fResponseSlicesFadc; i++) 47 fFadcResp[i] = 0.; 48 } 49 50 void MStarLight::Reset() { 51 52 10 53 fBrightness = 0. ; 11 fTimeRange = TIMERANGE ; 12 13 fBinsTrig = TRIGBINS ; 14 fTrigShape = 0. ; 15 fAmplTrig = 0. ; 16 fFwhmTrig = 0. ; 17 18 fBinsFadc = FADCBINS ; 19 fFadcShape = 0. ; 20 fIntegFadc = 0. ; 21 fFwhmFadc = 0. ; 22 23 24 for (Int_t i= 0; i< TRIGBINS ; i++) 25 fTrig[i] = 0. ; 26 27 for (Int_t i= 0; i<FADCBINS; i++) 28 fFadc[i] = 0. ; 29 30 for (Int_t i= 0; i<40; i++) 31 fTrigResp[i] = 0. ; 32 33 for (Int_t i= 0; i<45; i++) 34 fFadcResp[i] = 0. ; 35 } 36 37 void MStarLight::Reset() { 38 39 40 fBrightness = 0. ; 41 fTimeRange = TIMERANGE ; 42 43 fBinsTrig = TRIGBINS ; 44 fTrigShape = 0. ; 45 fAmplTrig = 0. ; 46 fFwhmTrig = 0. ; 47 48 fBinsFadc = FADCBINS ; 49 fFadcShape = 0. ; 50 fIntegFadc = 0. ; 51 fFwhmFadc = 0. ; 52 53 54 for (Int_t i= 0; i< TRIGBINS ; i++) 55 fTrig[i] = 0. ; 56 57 for (Int_t i= 0; i<FADCBINS; i++) 58 fFadc[i] = 0. ; 59 60 for (Int_t i= 0; i<40; i++) 61 fTrigResp[i] = 0. ; 62 63 for (Int_t i= 0; i<45; i++) 64 fFadcResp[i] = 0. ; 65 } 66 67 54 fTimeRange = TIMERANGE; 55 56 fTrigShape = 0; 57 fAmplTrig = 0.; 58 fFwhmTrig = 0.; 59 60 fFadcShape = 0; 61 fIntegFadc = 0.; 62 fFwhmFadc = 0.; 63 64 65 for (Int_t i= 0; i < fBinsTrig ; i++) 66 fTrig[i] = 0.; 67 68 for (Int_t i= 0; i < fBinsFadc; i++) 69 fFadc[i] = 0.; 70 71 for (Int_t i = 0; i < RESPONSE_SLICES_TRIG; i++) 72 fTrigResp[i] = 0.; 73 74 for (Int_t i = 0; i < fResponseSlicesFadc; i++) 75 fFadcResp[i] = 0.; 76 } 68 77 69 78 Float_t MStarLight::GetBrightness () 70 79 { 71 return fBrightness 80 return fBrightness; 72 81 } 73 82 74 83 void MStarLight::SetBrightness (Float_t in ) 75 84 { 76 fBrightness = in 85 fBrightness = in; 77 86 } 78 87 79 88 Float_t MStarLight::GetAmplTrig () 80 89 { 81 return fAmplTrig 90 return fAmplTrig ; 82 91 } 83 92 84 93 void MStarLight::SetAmplTrig (Float_t in ) 85 94 { 86 fAmplTrig = in 95 fAmplTrig = in; 87 96 } 88 97 89 98 Float_t MStarLight::GetFwhmTrig () 90 99 { 91 return fFwhmTrig 100 return fFwhmTrig; 92 101 } 93 102 94 103 void MStarLight::SetFwhmTrig (Float_t in ) 95 104 { 96 fFwhmTrig = in ; 97 } 98 105 fFwhmTrig = in; 106 } 107 108 void MStarLight::SetFadcSlicesPerNanosec (Float_t in) 109 { 110 fFadcSlicesPerNanosec = in; 111 fBinsFadc = (Int_t)(fFadcSlicesPerNanosec*TIMERANGE); 112 113 if (fFadc) 114 delete [] fFadc; 115 116 fFadc = new Float_t[fBinsFadc]; 117 118 for (Int_t i= 0; i < fBinsFadc; i++) 119 fFadc[i] = 0.; 120 } 99 121 100 122 Float_t MStarLight::GetIntegFadc () 101 123 { 102 return fIntegFadc 124 return fIntegFadc; 103 125 } 104 126 105 127 void MStarLight::SetIntegFadc (Float_t in ) 106 128 { 107 fIntegFadc = in 129 fIntegFadc = in; 108 130 } 109 131 110 132 Float_t MStarLight::GetFwhmFadc () 111 133 { 112 return fFwhmFadc 134 return fFwhmFadc; 113 135 } 114 136 115 137 void MStarLight::SetFwhmFadc (Float_t in ) 116 138 { 117 fFwhmFadc = in ; 118 } 119 120 121 void MStarLight::SetTrigResponse( Float_t *in ) { 122 123 for (Int_t i= 0; i<40; i++) 124 fTrigResp[i] = in[i] ; 125 126 } 127 128 void MStarLight::SetFadcResponse( Float_t *in ) { 129 130 for (Int_t i= 0; i<45; i++) 131 fFadcResp[i] = in[i] ; 132 } 133 134 void MStarLight::FillResponse( Float_t ampl, Float_t time ) { 135 136 // fill the trigger response 137 138 Int_t startbin = (Int_t) (time * 4) ; 139 140 Int_t icount = 0 ; 141 Int_t idata ; 142 143 for ( Int_t i=startbin ; i<startbin+40 ; i++) { 144 // 145 if ( i < TRIGBINS ) 146 idata = i ; 147 else if ( i >= TRIGBINS ) 148 idata = i - TRIGBINS ; 149 150 fTrig[idata] = fTrig[idata] + ampl * fTrigResp[icount] ; 151 152 icount++ ; 153 } 139 fFwhmFadc = in; 140 } 141 142 143 void MStarLight::SetTrigResponse( Float_t *in ) 144 { 145 for (Int_t i = 0; i < RESPONSE_SLICES_TRIG; i++) 146 fTrigResp[i] = in[i]; 147 } 148 149 void MStarLight::SetFadcResponse( Float_t *in ) 150 { 151 for (Int_t i = 0; i < fResponseSlicesFadc; i++) 152 fFadcResp[i] = in[i]; 153 } 154 155 void MStarLight::FillResponse( Float_t ampl, Float_t time ) 156 { 157 // fill the trigger response 158 159 Int_t startbin = (Int_t) (time * ((Float_t)fBinsTrig/TIMERANGE)); 160 161 Int_t icount = 0; 162 Int_t idata; 163 164 for ( Int_t i = startbin ; i < startbin+RESPONSE_SLICES_TRIG ; i++) 165 { 166 if ( i < fBinsTrig ) 167 idata = i; 168 else if ( i >= fBinsTrig ) 169 idata = i - fBinsTrig; 170 171 fTrig[idata] = fTrig[idata] + ampl * fTrigResp[icount]; 172 icount++ ; 173 } 154 174 155 175 // … … 157 177 // 158 178 159 startbin = (Int_t) ( time / 0.6666666666);160 179 startbin = (Int_t) ( time * ((Float_t)(fBinsFadc*SUBBINS)/TIMERANGE)); 180 161 181 Int_t ichanfadc = 0 ; 162 182 163 183 // 164 184 // putting the response slices in the right sig slices. 165 // Be careful l, because both slices have different widths.185 // Be careful, because both slices have different widths. 166 186 // 167 187 … … 170 190 // the signal within each FADC slice, but measures just the signal height 171 191 // at one point, like the real FADC does. By default, each FADC slice 172 // contains 5 bins of the response histogram(fFadcResp[45]). Warning: 173 // do not change this unless you do the corresponding modifications also 174 // in MFadc.cxx, or the signal and the noise photoelectrons will be treated 175 // differently!! 176 // 177 178 for ( Int_t i = 0 ; i < 45; i += 5 ) { 179 ichanfadc = (Int_t) ((startbin+i)/5) ; 180 181 if ( (ichanfadc) < FADCBINS ) 182 idata = ichanfadc ; 183 else if ( ichanfadc >=FADCBINS ) 184 idata = ichanfadc-FADCBINS ; 185 186 fFadc[idata] += (ampl * fFadcResp[i] ) ; 187 188 } 189 192 // contains SUBBINS bins of the response histogram 193 // (fFadcResp). Warning: do not change this unless you do the corresponding 194 // modifications also in MFadc.cxx, or the signal and the noise photoelectrons 195 // will be treated differently!! 196 // 197 198 for ( Int_t i = 0 ; i < fResponseSlicesFadc; i += SUBBINS ) 199 { 200 ichanfadc = (Int_t) ((startbin+i)/(Float_t)SUBBINS); 201 202 if ( ichanfadc < fBinsFadc ) 203 idata = ichanfadc; 204 else if ( ichanfadc >= fBinsFadc ) 205 idata = ichanfadc-fBinsFadc; 206 207 fFadc[idata] += (ampl * fFadcResp[i]); 208 } 190 209 } 191 210 … … 197 216 TRandom2 wuerfel( (UInt_t) (noiseTrig*100) ) ; 198 217 199 for (Int_t i=0; i< TRIGBINS ; i++ ) { 200 fTrig[i] += wuerfel.Gaus(0., noiseTrig ) ; 201 } 202 203 for (Int_t i=0; i< FADCBINS ; i++ ) { 204 fFadc[i] += wuerfel.Gaus(0., noiseFadc ) ; 205 } 206 207 208 } 209 210 Float_t MStarLight::GetTrig( Int_t i){ 218 for (Int_t i=0; i< fBinsTrig ; i++ ) 219 fTrig[i] += wuerfel.Gaus(0., noiseTrig ); 220 221 for (Int_t i=0; i< fBinsFadc ; i++ ) 222 fFadc[i] += wuerfel.Gaus(0., noiseFadc ); 223 224 } 225 226 Float_t MStarLight::GetTrig( Int_t i) 227 { 211 228 //------------------------------------------------------------------ 212 229 // 213 // It gets the value of the simu alted trigger in the i bin230 // It gets the value of the simulated trigger in the i bin 214 231 // 215 232 return fTrig[i]; 216 233 } 217 234 218 Float_t MStarLight::GetFadc( Int_t i){ 235 Float_t MStarLight::GetFadc( Int_t i) 236 { 219 237 //------------------------------------------------------------------ 220 238 // 221 // It gets the value of the simu alted FADC signal in the i bin239 // It gets the value of the simulated FADC signal in the i bin 222 240 // 223 241 return fFadc[i]; 224 242 } 225 243 226 void MStarLight::StoreHisto( char *filename) {227 228 Float_t baseline = 0. ; 229 230 231 // first the histogram ms for trigger244 void MStarLight::StoreHisto( char *filename) 245 { 246 247 Float_t baseline = 0.; 248 249 // first the histograms for trigger 232 250 // 233 251 // the calculated trigger signal before baseline 234 252 // 235 253 236 TH1F trigresp ("trigresp", "Trigger Response", TRIGBINS, 0., TIMERANGE) ; 237 238 for (Int_t i=0; i< TRIGBINS ; i++ ) { 239 240 trigresp.SetBinContent(i, fTrig[i]) ; 241 242 baseline = baseline + fTrig[i] ; 243 } 244 245 baseline = baseline / TRIGBINS ; 254 TH1F trigresp ("trigresp", "Trigger Response", fBinsTrig, 0., TIMERANGE); 255 256 for (Int_t i=0; i< fBinsTrig ; i++ ) 257 { 258 trigresp.SetBinContent(i+1, fTrig[i]); 259 baseline += fTrig[i]; 260 } 261 262 baseline /= fBinsTrig; 246 263 247 264 TH1F trigbase ("trigbase", "Response after Baseline shift", 248 TRIGBINS, 0., TIMERANGE) ; 249 for (Int_t i=0; i< TRIGBINS ; i++ ) { 250 251 trigbase.SetBinContent(i, fTrig[i]-baseline ) ; 252 253 } 265 fBinsTrig, 0., TIMERANGE) ; 266 267 for (Int_t i = 0; i < fBinsTrig ; i++) 268 trigbase.SetBinContent(i+1, fTrig[i]-baseline ); 254 269 255 270 TH1F trigdist ("trigdist", "Noise on the baseline", 256 1000, -25., 25. ) ; 257 258 for (Int_t i=0; i< TRIGBINS ; i++ ) { 259 260 trigdist.Fill( (Float_t) trigbase.GetBinContent(i) ) ; 261 } 271 1000, -25., 25. ); 272 273 for (Int_t i = 0; i < fBinsTrig ; i++) 274 trigdist.Fill( (Float_t) trigbase.GetBinContent(i+1) ); 262 275 263 276 264 277 // 265 // second the histograms for the fadc 266 // 267 268 269 TH1F fadcresp ("fadcresp", "Fadc Response", FADCBINS, 0., TIMERANGE) ; 270 271 for (Int_t i=0; i< FADCBINS ; i++ ) { 272 273 fadcresp.SetBinContent(i, fFadc[i]) ; 274 275 baseline = baseline + fFadc[i] ; 276 } 277 278 baseline = baseline / FADCBINS ; 278 // Now the histograms for the fadc 279 // 280 281 TH1F fadcresp ("fadcresp", "Fadc Response", fBinsFadc, 0., TIMERANGE); 282 283 baseline = 0.; 284 for (Int_t i=0; i < fBinsFadc; i++) 285 { 286 fadcresp.SetBinContent(i+1, fFadc[i]); 287 baseline += fFadc[i]; 288 } 289 290 baseline /= fBinsFadc; 279 291 280 292 TH1F fadcbase ("fadcbase", "Fadc after Baseline shift", 281 FADCBINS, 0., TIMERANGE) ; 282 for (Int_t i=0; i< FADCBINS ; i++ ) { 283 284 fadcbase.SetBinContent(i, fFadc[i]-baseline ) ; 285 286 } 287 293 fBinsFadc, 0., TIMERANGE) ; 294 295 for (Int_t i=0; i< fBinsFadc ; i++ ) 296 fadcbase.SetBinContent(i+1, fFadc[i]-baseline ); 297 288 298 TH1F fadcdist ("fadcdist", "Noise on fadc", 289 299 1000, -100., 100. ) ; 290 300 291 for (Int_t i=0; i< FADCBINS ; i++ ) { 292 293 fadcdist.Fill( (Float_t) fadcbase.GetBinContent(i) ) ; 294 } 295 296 297 298 299 TFile outfile( filename, "UPDATE" ) ; 300 301 trigresp.Write() ; 302 trigbase.Write() ; 303 trigdist.Write() ; 304 305 fadcresp.Write() ; 306 fadcbase.Write() ; 307 fadcdist.Write() ; 308 309 310 outfile.Close() ; 311 } 312 313 void MStarLight::WriteBinary( char *filename) { 314 // 315 // write the things to the binary file 301 for (Int_t i=0; i< fBinsFadc ; i++ ) 302 fadcdist.Fill( (Float_t) fadcbase.GetBinContent(i+1) ); 303 304 TFile outfile( filename, "RECREATE"); 305 306 trigresp.Write(); 307 trigbase.Write(); 308 trigdist.Write(); 309 310 fadcresp.Write(); 311 fadcbase.Write(); 312 fadcdist.Write(); 313 314 315 outfile.Close(); 316 } 317 318 void MStarLight::WriteBinary( char *filename) 319 { 320 // 321 // write the information to the binary file 316 322 317 323 FILE *datei ; … … 319 325 datei = fopen ( filename, "w" ) ; 320 326 321 if ( ! datei ) {322 cout << " ERROR: Can't open the file " << filename323 << endl ; 324 exit (230) ;325 }327 if ( ! datei ) 328 { 329 cout << " ERROR: Can't open the file " << filename << endl; 330 exit (230); 331 } 326 332 327 333 Float_t version = VERSIONSR; … … 329 335 // write them out 330 336 331 fwrite ( &version, sizeof(Float_t), 1, datei ) ; 332 fwrite ( &fBrightness, sizeof(Float_t), 1, datei ) ; 333 fwrite ( &fTimeRange , sizeof(Float_t), 1, datei ) ; 334 335 fwrite ( &fBinsTrig , sizeof(Float_t), 1, datei ) ; 336 fwrite ( &fTrigShape , sizeof(Float_t), 1, datei ) ; 337 fwrite ( &fAmplTrig , sizeof(Float_t), 1, datei ) ; 338 fwrite ( &fFwhmTrig , sizeof(Float_t), 1, datei ) ; 339 340 fwrite ( &fBinsFadc , sizeof(Float_t), 1, datei ) ; 341 fwrite ( &fFadcShape , sizeof(Float_t), 1, datei ) ; 342 fwrite ( &fIntegFadc , sizeof(Float_t), 1, datei ) ; 343 fwrite ( &fFwhmFadc , sizeof(Float_t), 1, datei ) ; 344 345 fwrite ( &fTrig , sizeof(Float_t), TRIGBINS, datei ) ; 337 fwrite ( &version, sizeof(Float_t), 1, datei ); 338 fwrite ( &fBrightness, sizeof(Float_t), 1, datei ); 339 fwrite ( &fTimeRange, sizeof(Float_t), 1, datei ); 340 fwrite ( &fFadcSlicesPerNanosec, sizeof(Float_t), 1, datei ); 341 342 fwrite ( &fBinsTrig , sizeof(Int_t), 1, datei ); 343 fwrite ( &fTrigShape , sizeof(Int_t), 1, datei ); 344 fwrite ( &fAmplTrig , sizeof(Float_t), 1, datei ); 345 fwrite ( &fFwhmTrig , sizeof(Float_t), 1, datei ); 346 347 fwrite ( &fBinsFadc , sizeof(Int_t), 1, datei ); 348 fwrite ( &fFadcShape , sizeof(Int_t), 1, datei ); 349 fwrite ( &fIntegFadc , sizeof(Float_t), 1, datei ); 350 fwrite ( &fFwhmFadc , sizeof(Float_t), 1, datei ); 351 352 fwrite (fTrig, sizeof(Float_t), fBinsTrig, datei); 346 353 347 354 // We want to store the FADC signal taking into account the AC … … 351 358 // 352 359 353 Float_t baseline = 0. ; 354 355 for (Int_t i=0; i< FADCBINS ; i++ ) { 356 357 baseline = baseline + fFadc[i] ; 358 } 359 360 baseline = baseline / FADCBINS ; 361 362 for (Int_t i=0; i< FADCBINS ; i++ ) { 363 364 fFadc[i]=fFadc[i]-baseline; 365 366 } 367 368 fwrite ( &fFadc , sizeof(Float_t), FADCBINS, datei ) ; 369 370 371 fclose ( datei ) ; 360 Float_t baseline = 0.; 361 362 for (Int_t i=0; i< fBinsFadc ; i++ ) 363 baseline += fFadc[i]; 364 365 baseline /= fBinsFadc; 366 367 Float_t *temp = new Float_t[fBinsFadc]; 368 369 for (Int_t i=0; i < fBinsFadc; i++ ) 370 temp[i] = fFadc[i]-baseline; 371 372 fwrite (temp, sizeof(Float_t), fBinsFadc, datei); 373 374 delete [] temp; 375 376 fclose ( datei ); 372 377 373 378 } … … 393 398 394 399 Float_t read_version; 395 Float_t current_version =VERSIONSR;396 397 // Check t aht we read the right version of the Database400 Float_t current_version = VERSIONSR; 401 402 // Check that we read the right version of the Database 398 403 fread ( &read_version, sizeof(Float_t), 1, datei ) ; 399 404 400 405 if(Int_t(read_version)!=Int_t(current_version)){ 401 406 cout<<" ERROR: You are trying to read database VERSION "<< 402 read_version <<endl;407 read_version << endl; 403 408 cout<<" You must generate a database for the current VERSION "<< 404 current_version <<endl;409 current_version << endl; 405 410 cout<<" See the NSB database section in the Camera How to Use note." 406 411 <<endl; … … 408 413 } 409 414 410 fread ( &fBrightness, sizeof(Float_t), 1, datei ) ; 411 fread ( &fTimeRange , sizeof(Float_t), 1, datei ) ; 412 413 414 fread ( &fBinsTrig , sizeof(Float_t), 1, datei ) ; 415 fread ( &fTrigShape , sizeof(Float_t), 1, datei ) ; 416 fread ( &fAmplTrig , sizeof(Float_t), 1, datei ) ; 417 fread ( &fFwhmTrig , sizeof(Float_t), 1, datei ) ; 418 419 fread ( &fBinsFadc , sizeof(Float_t), 1, datei ) ; 420 fread ( &fFadcShape , sizeof(Float_t), 1, datei ) ; 421 fread ( &fIntegFadc , sizeof(Float_t), 1, datei ) ; 422 fread ( &fFwhmFadc , sizeof(Float_t), 1, datei ) ; 423 424 fread ( &fTrig , sizeof(Float_t), TRIGBINS, datei ) ; 425 426 fread ( &fFadc , sizeof(Float_t), FADCBINS, datei ) ; 427 428 415 fread ( &fBrightness, sizeof(Float_t), 1, datei ); 416 fread ( &fTimeRange , sizeof(Float_t), 1, datei ); 417 fread ( &fFadcSlicesPerNanosec, sizeof(Float_t), 1, datei ); 418 419 fread ( &fBinsTrig , sizeof(Int_t), 1, datei ); 420 fread ( &fTrigShape , sizeof(Int_t), 1, datei ); 421 fread ( &fAmplTrig , sizeof(Float_t), 1, datei ); 422 fread ( &fFwhmTrig , sizeof(Float_t), 1, datei ); 423 424 fread ( &fBinsFadc , sizeof(Int_t), 1, datei ); 425 fread ( &fFadcShape , sizeof(Int_t), 1, datei ); 426 fread ( &fIntegFadc , sizeof(Float_t), 1, datei ); 427 fread ( &fFwhmFadc , sizeof(Float_t), 1, datei ); 428 429 if (fTrig) 430 delete [] fTrig; 431 432 if (fFadc) 433 delete [] fFadc; 434 435 fTrig = new Float_t[fBinsTrig]; 436 fFadc = new Float_t[fBinsFadc]; 437 438 fread (fTrig, sizeof(Float_t), fBinsTrig, datei); 439 fread (fFadc, sizeof(Float_t), fBinsFadc, datei); 429 440 430 441 fclose ( datei ) ; 431 442 } 432 433 434 435 -
trunk/MagicSoft/Simulation/Detector/StarResponse/MStarLight.hxx
r5099 r5248 1 #include "MFadcDefine.h" 2 #include "MTriggerDefine.h" 3 1 4 #ifndef __MStarLight__ 2 5 #define __MStarLight__ … … 13 16 #include "TRandom2.h" 14 17 15 #define VERSIONSR 1002.0 16 #define TIMERANGE 10000. 17 #define TRIGBINS 40000 18 #define FADCBINS 3000 18 #define VERSIONSR 1003.0 19 #define TIMERANGE 10000 // ns 19 20 20 21 class MStarLight { … … 22 23 private: 23 24 24 Float_t fBrightness ;// the brightness of the star in phe/nsec25 Float_t fBrightness; // the brightness of the star in phe/nsec 25 26 26 Float_t fTimeRange 27 Float_t fTimeRange; // the time range of the trigger response 27 28 28 Float_t fBinsTrig ; // Number of Bins in the trigger29 Float_t fTrigShape; // a number that indicate the shape type of30 31 32 Float_t fAmplTrig ;// the amplitude of the trigger in mV33 Float_t fFwhmTrig ;// the width of the signal in nsec29 Int_t fBinsTrig; // Number of Bins in the trigger database 30 Int_t fTrigShape; // a number that indicate the shape type of 31 // the signal 32 // = 0 --> a gaussian 33 Float_t fAmplTrig; // the amplitude of the trigger in mV 34 Float_t fFwhmTrig; // the width of the signal in nsec 34 35 35 Float_t fBinsFadc ; // Number of Bins in the trigger36 Float_t fFadcShape; // a number that indicate the shape type of37 38 39 Float_t fIntegFadc ;// the integral of the single phe response40 41 Float_t fFwhmFadc ;// the width of the signal in nsec36 Int_t fBinsFadc; // Number of Bins in the FADC database 37 Int_t fFadcShape; // a number that indicate the shape type of 38 // the signal 39 // = 0 --> a gaussian 40 Float_t fIntegFadc; // the integral of the single phe response 41 // in the FADC (in FADC counts) 42 Float_t fFwhmFadc; // the width of the signal in nsec 42 43 43 Float_t fTrig[TRIGBINS] ; // 4.0 bins per nsec for 10000 nanoseconds 44 Float_t fFadc[FADCBINS] ; // 0.3 bins per nsec for 10000 nanoseconds 45 46 Float_t fTrigResp [ 40 ] ; // the shape of the response for trigger 47 Float_t fFadcResp [ 45 ] ; // the shape of the response for FADC 44 Float_t *fTrig; // Trigger branch "history" for 10000 nanoseconds 45 Float_t *fTrigResp; // the shape of the response for trigger 46 Float_t *fFadc; // FADC "history" for 10000 nanoseconds 47 Float_t *fFadcResp; // the shape of the response for FADC 48 49 Float_t fFadcSlicesPerNanosec; // Number of FADC slices per ns 50 // (may be < 1 if FADC is faster than 1 GHz) 51 52 Int_t fResponseSlicesFadc; 48 53 49 54 public: 50 51 MStarLight() ;52 55 53 void Reset() ; 56 MStarLight(Float_t fadc_slices_per_ns = 0., 57 Int_t response_slices_fadc = 0); 54 58 55 void SetBrightness( Float_t in ) ; 56 void SetAmplTrig( Float_t in ) ; 57 void SetFwhmTrig( Float_t in ) ; 58 void SetShapeFadc( Float_t in ) { fFadcShape=in;} 59 void SetIntegFadc( Float_t in ) ; 60 void SetFwhmFadc( Float_t in ) ; 59 void Reset(); 61 60 62 Float_t GetBrightness() ; 63 Float_t GetAmplTrig() ; 64 Float_t GetFwhmTrig() ; 65 Float_t GetShapeFadc() {return fFadcShape;} 66 Float_t GetIntegFadc() ; 67 Float_t GetFwhmFadc() ; 61 void SetBrightness(Float_t in); 62 void SetAmplTrig(Float_t in); 63 void SetFwhmTrig(Float_t in); 64 void SetShapeFadc(Int_t in) {fFadcShape=in;} 65 void SetIntegFadc(Float_t in); 66 void SetFwhmFadc(Float_t in); 67 void SetFadcSlicesPerNanosec(Float_t in); 68 68 69 void SetTrigResponse(Float_t *in) ;70 69 71 void SetFadcResponse(Float_t *in) ; 70 Float_t GetBrightness(); 71 Float_t GetAmplTrig(); 72 Float_t GetFwhmTrig(); 73 Int_t GetShapeFadc() {return fFadcShape;} 74 Float_t GetIntegFadc(); 75 Float_t GetFwhmFadc(); 76 Int_t GetBinsTrig() {return fBinsTrig;} 77 Int_t GetBinsFadc() {return fBinsFadc;} 78 Float_t GetTimeRange() {return fTimeRange;} 79 Float_t GetFadcSlicesPerNanosec() {return fFadcSlicesPerNanosec;} 72 80 73 void FillResponse(Float_t ampl, Float_t time) ; 81 void SetTrigResponse(Float_t *in); 82 void SetFadcResponse(Float_t *in); 74 83 75 void ElecNoise ( Float_t noiseTrig = 0.3 , Float_t noiseFadc = .5 ) ; 84 void FillResponse(Float_t ampl, Float_t time); 85 86 void ElecNoise ( Float_t noiseTrig = 0.3 , Float_t noiseFadc = .5 ); 76 87 77 88 Float_t GetTrig (Int_t i); 78 79 89 Float_t GetFadc (Int_t i); 80 90 81 void StoreHisto (char *filename ) ; 91 Float_t* GetTrigPointer (Int_t i) { return &(fTrig[i]); } 92 Float_t* GetFadcPointer (Int_t i) { return &(fFadc[i]); } 82 93 83 void WriteBinary (char *filename );94 void StoreHisto (char *filename ); 84 95 85 void ReadBinary (char *filename );96 void WriteBinary (char *filename ); 86 97 87 } ; 98 void ReadBinary (char *filename ); 99 100 }; 88 101 89 102 #endif -
trunk/MagicSoft/Simulation/Detector/StarResponse/srreadparam.cxx
r5099 r5248 19 19 //= 20 20 //= $RCSfile: srreadparam.cxx,v $ 21 //= $Revision: 1. 5$21 //= $Revision: 1.6 $ 22 22 //= $Author: moralejo $ 23 //= $Date: 2004- 09-17 13:51:02$23 //= $Date: 2004-10-12 13:41:09 $ 24 24 //= 25 25 //=////////////////////////////////////////////////////////////////////// … … 75 75 static float Simulated_Phe_p = 0.1; //@< precision for phe loop 76 76 static int FADC_Shape=0; 77 static float FADC_Integ=MFADC_RESPONSE_INTEGRAL; 78 static float FADC_FWHM=MFADC_RESPONSE_FWHM; 79 static int Trig_Shape=0; 80 static float Trig_Ampl=1.0; 81 static float Trig_FWHM=2.0; 82 static int Write_Root=0; 77 static float FADC_Integ = MFADC_RESPONSE_INTEGRAL; 78 static float FADC_FWHM = MFADC_RESPONSE_FWHM; 79 static float FADC_slices_per_ns = FADC_SLICES_PER_NSEC; 80 static int Trig_Shape = 0; 81 static float Trig_Ampl = 1.0; 82 static float Trig_FWHM = 2.0; 83 static int Write_Root = 0; 83 84 //!@} 84 85 … … 169 170 break; 170 171 172 case fadc_GHz: // Get FADC sampling frequency in GHz 173 174 sscanf(line, "%s %f", token, &FADC_slices_per_ns); 175 176 break; 177 171 178 case write_root: //@< Write histogram 172 179 … … 273 280 //!@{ 274 281 void 275 get_fadc_properties(int *shape, float *integ, float *fwhm )282 get_fadc_properties(int *shape, float *integ, float *fwhm, float *fadc_spns) 276 283 { 277 284 *shape = FADC_Shape; 278 285 *integ = FADC_Integ; 279 *fwhm = FADC_FWHM; 286 *fwhm = FADC_FWHM; 287 *fadc_spns = FADC_slices_per_ns; 280 288 } 281 289 //!@} … … 306 314 // 307 315 // $Log: not supported by cvs2svn $ 316 // Revision 1.5 2004/09/17 13:51:02 moralejo 317 // 318 // Adapted headers to current c++ style, removed -Wno-deprecated from 319 // compilation options. 320 // 308 321 // Revision 1.4 2004/09/16 16:20:13 moralejo 309 322 // *** empty log message *** -
trunk/MagicSoft/Simulation/Detector/StarResponse/srreadparam.h
r5099 r5248 19 19 //= 20 20 //= $RCSfile: srreadparam.h,v $ 21 //= $Revision: 1. 4$21 //= $Revision: 1.5 $ 22 22 //= $Author: moralejo $ 23 //= $Date: 2004- 09-17 13:51:02$23 //= $Date: 2004-10-12 13:41:09 $ 24 24 //= 25 25 //=////////////////////////////////////////////////////////////////////// … … 91 91 T(trig_properties), /* shape for the single phe trigger response */ \ 92 92 T(fadc_properties), /* shape for the single phe fadc response */ \ 93 T(fadc_GHz), /* FADC sampling frequency in GHz */ \ 93 94 T(write_root), /* write root file with some histograms */ \ 94 95 T(end_file) /* end of the parameters file */ … … 128 129 void get_simulated_phe(float *lphe, float *uphe, float *pphe); 129 130 void get_trig_properties(int *shape, float *ampl, float *fwhm); 130 void get_fadc_properties(int *shape, float *ampl, float *fwhm );131 void get_fadc_properties(int *shape, float *ampl, float *fwhm, float *slicesperns); 131 132 int get_write_root(); 132 133 //!@} … … 145 146 /* 146 147 * $Log: not supported by cvs2svn $ 148 * Revision 1.4 2004/09/17 13:51:02 moralejo 149 * 150 * Adapted headers to current c++ style, removed -Wno-deprecated from 151 * compilation options. 152 * 147 153 * Revision 1.3 2004/09/16 16:20:13 moralejo 148 154 * *** empty log message *** -
trunk/MagicSoft/Simulation/Detector/StarResponse/starresponse.cxx
r5099 r5248 23 23 TRandom2 Zufall( (UInt_t) brightness * 100) ; // a random generator 24 24 25 MStarLight data ; // create instance of the MStarLight 25 MStarLight data(fadc->GetFadcSlicesPerNanosec(), fadc->GetResponseSlicesFadc()); 26 // create instance of the MStarLight 26 27 27 28 // Shall I write the root file??? … … 31 32 write_root= get_write_root(); 32 33 34 Float_t trigresp[RESPONSE_SLICES_TRIG]; 35 33 36 // Get information from Trigger instance!!! 34 35 cout << sizeof (trigger) << endl ; 37 trigger->GetResponse(trigresp); 38 data.SetTrigResponse(trigresp); 39 40 data.SetAmplTrig ( trigger->GetAmplitude() ); 41 data.SetFwhmTrig ( trigger->GetFwhm() ); 42 43 Float_t *fadcresp = new Float_t[fadc->GetResponseSlicesFadc()]; 36 44 37 Float_t trigresp[40] ;38 trigger->GetResponse ( trigresp ) ;39 data.SetTrigResponse( trigresp ) ;40 41 data.SetAmplTrig ( trigger->GetAmplitude() ) ;42 data.SetFwhmTrig ( trigger->GetFwhm() ) ;43 44 45 // Get information from FADC instance !!!!! 46 fadc->GetResponse(fadcresp); 47 data.SetFadcResponse(fadcresp); 45 48 46 Float_t fadcresp[45] ; 47 fadc->GetResponse (fadcresp ) ; 48 data.SetFadcResponse( fadcresp ) ; 49 50 data.SetShapeFadc ( fadc->GetShape() ) ; 51 data.SetIntegFadc ( fadc->GetIntegral() ) ; 52 data.SetFwhmFadc ( fadc->GetFwhm() ) ; 49 data.SetShapeFadc ( fadc->GetShape() ); 50 data.SetIntegFadc ( fadc->GetIntegral() ); 51 data.SetFwhmFadc ( fadc->GetFwhm() ); 53 52 54 53 // start with the loop over random events 55 54 // 56 55 57 Float_t a = 0. 58 Float_t time = 0. 56 Float_t a = 0.; // the amplitude of the signal 57 Float_t time = 0.; // the time of the phe 59 58 60 for (Int_t i = 0 ; i< (Int_t ) (brightness * TIMERANGE) ; i++) {61 62 a = trigger->FillStar( 500, 10.) ; // random the amplitude63 time=Zufall.Rndm() * TIMERANGE ; // random the time59 for (Int_t i = 0; i < (Int_t) (brightness * TIMERANGE) ; i++) 60 { 61 a = trigger->FillStar( 500, 10.) ; // random the amplitude 62 time=Zufall.Rndm() * TIMERANGE ; // random the time 64 63 65 data.FillResponse(a, time ) ; // fill the response function 66 67 } 64 data.FillResponse(a, time ) ; // fill the response function 65 } 68 66 69 67 if(brightness<=1.0) … … 71 69 else 72 70 sprintf(filename, "%sBrightness%.1f.slt", path, brightness) ; 73 data.WriteBinary( filename ) ;74 71 75 data. Reset() ;72 data.WriteBinary( filename ); 76 73 77 if(write_root){ 78 data.ReadBinary( filename ) ; 79 80 if(brightness<1.0) 81 sprintf(filename, "%sBrightness%.2f.root", path, brightness) ; 82 else 83 sprintf(filename, "%sBrightness%.1f.root", path, brightness) ; 84 sprintf(filename, "%sBrightness%.2f.root", path, brightness) ; 85 cout << " the file will be written in " << filename 86 << endl ; 74 if(write_root) 75 { 76 if(brightness<=1.0) 77 sprintf(filename, "%sBrightness%.2f.root", path, brightness); 78 else 79 sprintf(filename, "%sBrightness%.1f.root", path, brightness); 87 80 88 data.StoreHisto( filename ) ; 89 } 81 cout << " the file will be written in " << filename << endl; 90 82 91 return (0) ; 83 data.StoreHisto( filename ); 84 } 85 86 data.Reset(); 87 88 return(0); 92 89 93 90 } … … 112 109 float trig_fwhm,trig_ampl; 113 110 float fadc_fwhm,fadc_integral; 114 int fadc_shape, trig_shape; 111 float fadc_slices_per_ns; 112 Int_t fadc_shape, trig_shape; 115 113 116 114 // … … 120 118 121 119 // Instance of MFadc and MTrigger needed inside BuildStarLight 122 MTrigger *trigger;//= new MTrigger(1); 123 MFadc *fadc;//= new MFadc; 120 121 MTrigger *trigger; 122 MFadc *fadc; 124 123 125 124 if(argc == 1){ … … 142 141 trigger = new MTrigger(1,0.,0.,trig_ampl,trig_fwhm); 143 142 144 get_fadc_properties(&fadc_shape, &fadc_integral, &fadc_fwhm); 145 fadc = new MFadc(1,fadc_shape,fadc_integral,fadc_fwhm,fadc_shape,fadc_integral,fadc_fwhm); 143 get_fadc_properties(&fadc_shape, &fadc_integral, &fadc_fwhm, &fadc_slices_per_ns); 146 144 147 for (Float_t b=nphe_min; b<=nphe_max; b=b+nphe_pre ) // loop over Brightness 148 { 149 BuildStarLight (b, path, trigger, fadc ) ; 150 } 145 fadc = new MFadc(1, fadc_shape, fadc_integral, fadc_fwhm, 146 fadc_shape, fadc_integral, fadc_fwhm, 0., fadc_slices_per_ns); 147 148 // loop over Brightness 149 150 // Limit precision (for speed reasons). Below 1 phe/ns/pixel we build the database 151 // files in steps of 0.01 (minimum). Above 1 phe/ns/pixel the steps are of 0.1 at least. 152 // These values can be made larger through the input card of starresponse 153 154 nphe_pre = nphe_pre < 0.01? 0.01 : nphe_pre; 155 for (Float_t b = nphe_min; b <= 1.0; b += nphe_pre ) 156 BuildStarLight (b, path, trigger, fadc); 157 158 nphe_pre = nphe_pre < 0.1? 0.1 : nphe_pre; 159 for (Float_t b = 1.0+nphe_pre; b <= nphe_max; b += nphe_pre ) 160 BuildStarLight (b, path, trigger, fadc); 161 151 162 delete(trigger); 152 163 delete(fadc);
Note:
See TracChangeset
for help on using the changeset viewer.