Changeset 5248 for trunk/MagicSoft/Simulation/Detector
- Timestamp:
- 10/12/04 14:43:18 (20 years ago)
- Location:
- trunk/MagicSoft/Simulation/Detector
- Files:
-
- 11 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); -
trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx
r5099 r5248 20 20 using namespace std; 21 21 22 MFadc::MFadc(Int_t pix, Int_t shape, Float_t integral, Float_t fwhm, Int_t shapeout, Float_t integralout, Float_t fwhmout, Float_t trigger_delay) { 22 MFadc::MFadc(Int_t pix, Int_t shape, Float_t integral, Float_t fwhm, 23 Int_t shapeout, Float_t integralout, Float_t fwhmout, 24 Float_t trigger_delay, Float_t fadc_slices_per_ns, 25 Int_t fadc_slices_written) { 23 26 // 24 27 // Constructor overloaded II … … 45 48 fwhm_resp_outer = fwhmout; 46 49 integ_resp_outer = integralout; 47 shape_resp=shape; 48 shape_resp_outer=shapeout; 49 50 cout<< "[MFadc] Setting up the MFadc with this values "<< endl ; 51 cout<< "[MFadc] - Inner pixels : "<< endl ; 50 shape_resp = shape; 51 shape_resp_outer = shapeout; 52 fFadcSlicesPerNanosec = fadc_slices_per_ns; 53 fFadcSlices = fadc_slices_written; 54 55 fSlices_mFadc = (Int_t)(TOTAL_TRIGGER_TIME*fFadcSlicesPerNanosec); 56 57 for (Int_t i = 0; i < CAMERA_PIXELS; i++) 58 sig[i] = new Float_t[fSlices_mFadc]; 59 60 noise = new Float_t[fSlices_mFadc*1001]; 61 noise_outer = new Float_t[fSlices_mFadc*1001]; 62 digital_noise = new Float_t[fSlices_mFadc*1001]; 63 64 for (Int_t i = 0; i < CAMERA_PIXELS; i++) 65 { 66 output[i] = new Float_t[fFadcSlices]; 67 output_lowgain[i] = new Float_t[fFadcSlices]; 68 } 69 70 cout<< "[MFadc] Setting up the MFadc with this values "<< endl ; 71 cout<< "[MFadc] FADC sampling frequency: " << fFadcSlicesPerNanosec << " GHz" << endl ; 72 cout<< "[MFadc] - Inner pixels : "<< endl ; 73 52 74 switch(shape_resp){ 53 75 case 0: … … 82 104 // set up the response shape 83 105 // 106 107 // 108 // First select number of bins for the histogram which will contain the single 109 // photoelectron response of the FADC. The width of these bins is smaller than that 110 // of the real FADC slices by a factor SUBBINS (see MFadcDefine.h): 111 // 112 if (shape_resp == 1) 113 fResponseSlicesFadc = (Int_t)(50.*fFadcSlicesPerNanosec*SUBBINS); 114 // 50 ns range 115 116 else 117 fResponseSlicesFadc = (Int_t)(7*fwhm_resp/2.35*fFadcSlicesPerNanosec*SUBBINS); 118 // 7 sigma range 119 120 sing_resp = new Float_t[fResponseSlicesFadc]; 121 sing_resp_outer = new Float_t[fResponseSlicesFadc]; 122 84 123 Int_t i ; 85 124 … … 92 131 response_sum_outer = 0.; 93 132 94 dX = WIDTH_FADC_TIMESLICE/ SUBBINS ; // Units: ns133 dX = 1. / fFadcSlicesPerNanosec / SUBBINS ; // Units: ns 95 134 dX2 = dX/2. ; 96 135 … … 102 141 fadc_time_offset = trigger_delay-x0; // ns 103 142 104 for (i =0; i< RESPONSE_SLICES_MFADC ; i++ ) {105 106 143 for (i = 0; i < fResponseSlicesFadc ; i++ ) 144 { 145 x = i * dX + dX2 ; 107 146 108 sing_resp[i] = expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) );109 110 111 }147 sing_resp[i] = (Float_t)(expf(-0.5*(x-x0)*(x-x0)/(sigma*sigma))); 148 149 response_sum_inner += sing_resp[i]; 150 } 112 151 113 152 break; … … 121 160 p1 = 2.066; 122 161 p2 = 1.568; 123 p3 = 3; // This sets the peak of the pulse at x ~ 3 ADC slices162 p3 = 3; // This will set the peak of the pulse at x ~ 3*3.3 = 10 ns 124 163 // It is just a safe value so that the pulse is well contained. 125 164 p4 = 0.00282; … … 127 166 p6 = 0.2411; 128 167 p7 = -0.009442; 129 // Define the time before trigger to read FADC signal when it 130 // has to be written 131 fadc_time_offset = trigger_delay-p3*WIDTH_FADC_TIMESLICE; // ns 132 133 for (i=0; i< RESPONSE_SLICES_MFADC ; i++ ) { 134 x = i * dX + dX2; 135 136 // x has to be converted from ns to units FADC slices: 137 zed_slices=x/WIDTH_FADC_TIMESLICE-p3; 138 d=(zed_slices>0)?0.5:-0.5; 139 140 sing_resp[i] = (p1*exp(-p2*(exp(-p2*zed_slices)+zed_slices))+p4+ 141 p5*exp(-p2*(exp(-p2*zed_slices)+p6*zed_slices))+p7*d); 142 143 response_sum_inner += sing_resp[i]; 144 } 168 169 // Now define the time before trigger to read FADC signal when it 170 // has to be written. Here FADC_SLICES_PER_NSEC (=0.3) is the value 171 // for the 300 MHz MAGIC FADCs and must NOT be changed, even if you 172 // use a faster sampling in the simulation (through the input card 173 // command "fadc_GHz"), because this is just a conversion of units. The 174 // parameters of the "pulpo" pulse shape were obtained with the 300 MHz 175 // FADC and so we convert the time parameter to units of 3.3 ns slices 176 // just to use the provided parametrization, and no matter what sampling 177 // frequency we are simulating! 178 179 fadc_time_offset = trigger_delay - p3 / FADC_SLICES_PER_NSEC; // ns 180 181 for (i=0; i< fResponseSlicesFadc ; i++ ) 182 { 183 x = i * dX + dX2; 184 185 // x has to be converted from ns to units FADC slices of the default 186 // FADC of 300 MHz (these are just units, and must be these even if you 187 // are using another sampling frequency!): 188 // 189 zed_slices = x * FADC_SLICES_PER_NSEC - p3; 190 d=(zed_slices>0)?0.5:-0.5; 191 192 sing_resp[i] = (Float_t) (p1*exp(-p2*(exp(-p2*zed_slices)+zed_slices))+ 193 p4+p5*exp(-p2*(exp(-p2*zed_slices)+ 194 p6*zed_slices))+p7*d); 195 196 response_sum_inner += sing_resp[i]; 197 } 145 198 146 199 break; … … 162 215 fadc_time_offset = trigger_delay-x0; // ns 163 216 164 for (i=0; i< RESPONSE_SLICES_MFADC ; i++ ) { 217 for (i = 0; i < fResponseSlicesFadc ; i++ ) 218 { 219 x = i * dX + dX2 ; 165 220 166 x = i * dX + dX2 ; 167 168 // 169 // the value 1/sqrt(2*Pi*sigma^2) was introduced to normalize 170 // the area at the input value After this, the integral 171 // of the response will be integ_resp. 172 // 173 sing_resp_outer[i] = expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ; 174 response_sum_outer += sing_resp_outer[i]; 175 } 221 // 222 // the value 1/sqrt(2*Pi*sigma^2) was introduced to normalize 223 // the area at the input value After this, the integral 224 // of the response will be integ_resp. 225 // 226 sing_resp_outer[i] = (Float_t) (expf(-0.5 * (x-x0)*(x-x0) / 227 (sigma*sigma)) ) ; 228 response_sum_outer += sing_resp_outer[i]; 229 } 176 230 break; 177 231 case 1: … … 184 238 p1 = 2.066; 185 239 p2 = 1.568; 186 p3 = 3; // This sets the peak of the pulse at x ~ 3 ADC slices187 240 p3 = 3; // This sets the peak of the pulse at x ~ 3*3.3 = 10 nanosec 241 // It is just a safe value so that the pulse is well contained. 188 242 p4 = 0.00282; 189 243 p5 = 0.04093; 190 244 p6 = 0.2411; 191 245 p7 = -0.009442; 192 // Define the time before trigger to read FADC signal when it 193 // has to be written 194 fadc_time_offset = trigger_delay-p3*WIDTH_FADC_TIMESLICE; // ns 195 196 for (i=0; i< RESPONSE_SLICES_MFADC ; i++ ) { 197 x = i * dX + dX2; 198 199 zed_slices=x/WIDTH_FADC_TIMESLICE-p3; 200 d=(zed_slices>0)?0.5:-0.5; 201 202 sing_resp_outer[i] = (p1*exp(-p2*(exp(-p2*zed_slices)+zed_slices))+p4+ 203 p5*exp(-p2*(exp(-p2*zed_slices)+p6*zed_slices))+p7*d); 204 response_sum_outer += sing_resp_outer[i]; 246 247 // Now define the time before trigger to read FADC signal when it 248 // has to be written. Here FADC_SLICES_PER_NSEC (=0.3) is the value 249 // for the 300 MHz MAGIC FADCs and must NOT be changed, even if you 250 // use a faster sampling in the simulation (through the input card 251 // command "fadc_GHz"), because this is just a conversion of units. The 252 // parameters of the "pulpo" pulse shape were obtained with the 300 MHz 253 // FADC and so we convert the time parameter to units of 3.3 ns slices 254 // just to use the provided parametrization, and no matter what sampling 255 // frequency we are simulating! 256 257 fadc_time_offset = trigger_delay - p3 / FADC_SLICES_PER_NSEC; // ns 258 259 for (i=0; i< fResponseSlicesFadc ; i++ ) 260 { 261 x = i * dX + dX2; 262 263 // x has to be converted from ns to units FADC slices of the default 264 // FADC of 300 MHz (these are just units, and must be these even if you 265 // are using another sampling frequency!): 266 // 267 zed_slices = x * FADC_SLICES_PER_NSEC - p3; 268 d=(zed_slices>0)?0.5:-0.5; 269 270 sing_resp_outer[i] = (Float_t) (p1*exp(-p2*(exp(-p2*zed_slices)+ 271 zed_slices))+p4+ 272 p5*exp(-p2*(exp(-p2*zed_slices)+ 273 p6*zed_slices))+p7*d); 274 response_sum_outer += sing_resp_outer[i]; 205 275 } 206 276 break; … … 220 290 // 221 291 222 for (i=0; i< RESPONSE_SLICES_MFADC ; i++ ) { 292 for (i=0; i< fResponseSlicesFadc ; i++ ) 293 { 223 294 sing_resp[i] *= integ_resp / response_sum_inner * SUBBINS; 224 295 sing_resp_outer[i] *= integ_resp_outer / response_sum_outer * SUBBINS; 225 }296 } 226 297 227 298 // … … 250 321 // 251 322 memset(used, 0, CAMERA_PIXELS*sizeof(Bool_t)); 252 memset(output, 0, CAMERA_PIXELS*FADC_SLICES*sizeof(Float_t)); 253 memset(output_lowgain, 0, CAMERA_PIXELS*FADC_SLICES*sizeof(Float_t)); 323 324 for (Int_t i = 0; i < CAMERA_PIXELS; i++) 325 { 326 memset(output[i], 0, fFadcSlices*sizeof(Float_t)); 327 memset(output_lowgain[i], 0, fFadcSlices*sizeof(Float_t)); 328 } 329 254 330 // 255 331 // Added 15 01 2004, AM: 256 332 // 257 memset(sig, 0, (Int_t)(CAMERA_PIXELS*SLICES_MFADC*sizeof(Float_t))); 333 for (Int_t i = 0; i < CAMERA_PIXELS; i++) 334 memset(sig[i], 0, (Int_t)(fSlices_mFadc*sizeof(Float_t))); 258 335 } 259 336 void MFadc::Fill( Int_t iPix, Float_t time, … … 277 354 // fills the information about one single Phe in the Trigger class 278 355 // 279 // parameter is the number of the pixel and the time-difference to the 280 // first particle 281 // 282 // 356 // Parameters are the number of the pixel and the time-difference to the 357 // first photon. 358 // 359 // 360 // AM, Jan 2004: Replaced former FADC simulation (integration of signal) 361 // with a more realistic one (measuring signal height at discrete points). 362 // 363 283 364 284 365 Int_t i, ichan, ichanfadc ; … … 286 367 // 287 368 // first we have to check if the pixel iPix is used or not until now 288 // if this is the first use, reset all signal for that pixel s369 // if this is the first use, reset all signal for that pixel 289 370 // 290 if ( iPix > numpix ) { 291 cout << " WARNING: MFadc::Fill() : iPix greater than Pixels in Camera = " 292 << numpix 293 << endl ; 294 exit(987) ; 295 } 296 297 if ( used[iPix] == FALSE ) { 298 used [iPix] = TRUE ; 371 if ( iPix > numpix ) 372 { 373 cout << " WARNING: MFadc::Fill() : iPix greater than Pixels in Camera = " 374 << numpix 375 << endl; 376 exit(987); 377 } 378 379 if ( used[iPix] == FALSE ) 380 { 381 used [iPix] = TRUE; 299 382 300 for (i=0; i < (Int_t) SLICES_MFADC; i++ ) { 301 sig[iPix][i] = 0. ; 302 } 303 } 304 305 // 306 // then select the time slice to use (ican) 383 for (i=0; i < (Int_t) fSlices_mFadc; i++ ) 384 sig[iPix][i] = 0.; 385 } 386 387 // 388 // then select the time slice to use (ichan) 307 389 // 308 390 309 391 if ( time < TOTAL_TRIGGER_TIME+fadc_time_offset ) { 310 392 // 311 // determine the slices number assuming the WIDTH_RESPONSE_MFADC 312 // ichan marks the start of the pulse, in number of bins of width 313 // WIDTH_RESPONSE_MFADC (2/3 of a ns), measured from the start of the 314 // FADC. 315 // 316 317 ichan = (Int_t) ( time / ((Float_t) WIDTH_RESPONSE_MFADC )); 393 // Convert time into units of the width of the analog 394 // signal histogram, sing_resp: 395 // 396 ichan = (Int_t) ( time * fFadcSlicesPerNanosec * SUBBINS); 318 397 319 398 // 320 399 // putting the response slices in the right sig slices. 321 // Be carefull, because both slices have different widths. 322 // 323 324 // 325 // AM, Jan 2004: Replaced former FADC simulation (integration of signal) 326 // with a more realistic one (measuring signal height at discrete points). 327 // 400 // Be careful, because both slices have different widths. 401 // 402 403 // We want to put the single phe response given by sing_resp into the 404 // array sig[][], but only one of each SUBBINS bins, since the binning 405 // of sing_resp is finer than that of sig[][]. We want that the start of 406 // sing_resp coincides with the time "time" with respect to the begining 407 // of sig[][] 328 408 329 409 // We take the pulse height in the middle of FADC slices, we start in the … … 332 412 333 413 Int_t first_i = Int_t(SUBBINS/2) - ichan%(Int_t)SUBBINS; 334 first_i = first_i < 0 ? (Int_t)SUBBINS+first_i : first_i; 335 336 337 for ( i = first_i ; i < (Int_t)RESPONSE_SLICES; i += (Int_t)SUBBINS) { 338 ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ; 339 if ( ichanfadc < 0 ) 414 first_i = first_i < 0 ? (Int_t)SUBBINS+first_i : first_i; // 415 // 416 // first_i is the first bin of sing_resp which matches the center of one 417 // bin of sig[][] 418 // 419 420 for ( i = first_i ; i < (Int_t)fResponseSlicesFadc; i += (Int_t)SUBBINS) 421 { 422 ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ; 423 if ( ichanfadc < 0 ) 340 424 continue; 341 425 342 // 343 // SLICES_MFADC is by default 48. sig[][] is not the true FADC, which 344 // is filled from sig[][] in MFadc::TriggeredFadc() 345 // 346 if ( (ichanfadc) < (Int_t)SLICES_MFADC ) { 347 sig[iPix][ichanfadc] += (amplitude * sing_resp[i] ) ; 348 } 349 } 350 351 } 352 else { 426 // 427 // fSlices_mFadc is by default 48. sig[][] is not the true FADC, which 428 // is filled (from sig[][]) in MFadc::TriggeredFadc() 429 // 430 if ( (ichanfadc) < (Int_t) fSlices_mFadc ) 431 sig[iPix][ichanfadc] += (amplitude * sing_resp[i] ); 432 } 433 434 } 435 else 353 436 cout << " WARNING! Fadc::Fill " << time << " out of TriggerTimeRange " 354 437 << TOTAL_TRIGGER_TIME+fadc_time_offset << endl ; 355 }356 438 357 439 } … … 363 445 // for an outer pixel 364 446 // 365 // parameter is the number of the pixel and the time-difference to the 366 // first particle 367 // 447 // See explanations of the code in function Fill() above 368 448 // 369 449 370 450 Int_t i, ichan, ichanfadc ; 371 451 372 // 373 // first we have to check if the pixel iPix is used or not until now 374 // if this is the first use, reset all signal for that pixels 375 // 376 if ( iPix > numpix ) { 377 cout << " WARNING: MFadc::FillOuter() : iPix greater than CAMERA_PIXELS" 378 << endl ; 379 exit(987) ; 380 } 381 382 if ( used[iPix] == FALSE ) { 383 used [iPix] = TRUE ; 452 if ( iPix > numpix ) 453 { 454 cout << " WARNING: MFadc::FillOuter() : iPix greater than CAMERA_PIXELS" 455 << endl ; 456 exit(987) ; 457 } 458 459 if ( used[iPix] == FALSE ) 460 { 461 used [iPix] = TRUE ; 384 462 385 for (i=0; i < (Int_t) SLICES_MFADC; i++ ) { 386 sig[iPix][i] = 0. ; 387 } 388 } 389 390 // 391 // then select the time slice to use (ican) 392 // 463 for (i=0; i < (Int_t) fSlices_mFadc; i++) 464 sig[iPix][i] = 0.; 465 } 393 466 394 467 395 468 if ( time < TOTAL_TRIGGER_TIME+fadc_time_offset ) { 396 // 397 // determine the slices number assuming the WIDTH_RESPONSE_MFADC 398 // 399 ichan = (Int_t) ( time / ((Float_t) WIDTH_RESPONSE_MFADC )); 400 401 // 402 // putting the response slices in the right sig slices. 403 // Be carefull, because both slices have different widths. 404 // 405 406 // 407 // AM, Jan 2004: Replaced former FADC simulation (integration of signal) 408 // with a more realistic one (measuring signal height at discrete points). 409 // 410 411 // We take the pulse height in the middle of FADC slices, we start in the 412 // first such point after the time "time" (=ichan in response bins). Each 413 // FADC slice corresponds to SUBBINS response bins (SUBBINS=5 by default). 469 470 ichan = (Int_t) ( time * fFadcSlicesPerNanosec * SUBBINS); 414 471 415 472 Int_t first_i = Int_t(SUBBINS/2) - ichan%(Int_t)SUBBINS; 416 473 first_i = first_i < 0 ? (Int_t)SUBBINS+first_i : first_i; 417 474 418 for ( i = first_i ; i < (Int_t)RESPONSE_SLICES; i += (Int_t)SUBBINS) { 419 ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ; 420 421 if ( ichanfadc < 0 ) 475 for ( i = first_i ; i < (Int_t)fResponseSlicesFadc; i += (Int_t)SUBBINS) 476 { 477 ichanfadc = (Int_t) ((ichan+i)/SUBBINS); 478 479 if ( ichanfadc < 0 ) 422 480 continue; 423 481 424 if ( (ichanfadc) < (Int_t)SLICES_MFADC ) { 425 sig[iPix][ichanfadc] += (amplitude * sing_resp_outer[i] ) ; 426 } 427 } 428 482 if ( (ichanfadc) < (Int_t)fSlices_mFadc ) 483 sig[iPix][ichanfadc] += (amplitude * sing_resp_outer[i] ); 484 } 485 429 486 } 430 487 else { … … 432 489 << TOTAL_TRIGGER_TIME+fadc_time_offset << endl ; 433 490 } 434 435 } 436 437 void MFadc::Set( Int_t iPix, Float_t resp[(Int_t) SLICES_MFADC]) {491 492 } 493 494 void MFadc::Set( Int_t iPix, Float_t *resp) { 438 495 439 496 // … … 459 516 used [iPix] = TRUE ; 460 517 461 for (i=0; i < (Int_t) SLICES_MFADC; i++ ) {518 for (i=0; i < (Int_t)fSlices_mFadc; i++ ) { 462 519 sig[iPix][i] = 0. ; 463 520 } 464 521 } 465 for ( i = 0 ; i<(Int_t) SLICES_MFADC; i++ ) {522 for ( i = 0 ; i<(Int_t)fSlices_mFadc; i++ ) { 466 523 sig[iPix][i] = resp[i] ; 467 524 } … … 469 526 } 470 527 471 void MFadc::AddSignal( Int_t iPix, Float_t resp[(Int_t) SLICES_MFADC]) {528 void MFadc::AddSignal( Int_t iPix, Float_t *resp) { 472 529 473 530 // … … 493 550 used [iPix] = TRUE ; 494 551 495 for (i=0; i < (Int_t) SLICES_MFADC; i++ ) {552 for (i=0; i < (Int_t)fSlices_mFadc; i++ ) { 496 553 sig[iPix][i] = 0. ; 497 554 } 498 555 } 499 for ( i = 0 ; i<(Int_t) SLICES_MFADC; i++ ) {556 for ( i = 0 ; i<(Int_t)fSlices_mFadc; i++ ) { 500 557 sig[iPix][i] += resp[i] ; 501 558 } … … 534 591 for(j=0;j<numpix;j++){ 535 592 baseline=0.0; 536 for(i=0;i<(Int_t) SLICES_MFADC;i++){593 for(i=0;i<(Int_t) fSlices_mFadc;i++){ 537 594 baseline+=sig[j][i]; 538 595 } 539 baseline=baseline/ SLICES_MFADC;540 for(i=0;i<(Int_t) SLICES_MFADC;i++){596 baseline=baseline/fSlices_mFadc; 597 for(i=0;i<(Int_t) fSlices_mFadc;i++){ 541 598 sig[j][i]=-baseline; 542 599 } … … 554 611 555 612 for(i=0;i<numpix;i++) 556 for(j=0;j<(Int_t) SLICES_MFADC;j++)613 for(j=0;j<(Int_t)fSlices_mFadc;j++) 557 614 sig[i][j]+=pedestal[i]; 558 615 // … … 562 619 // to do it for all pixels. 563 620 // 564 565 566 621 } 567 622 … … 585 640 if (used[i]){ 586 641 fdum=(10*GenOff->Rndm()); 587 for(j=0;j<(Int_t) SLICES_MFADC;j++)642 for(j=0;j<(Int_t) fSlices_mFadc;j++) 588 643 sig[i][j]+=fdum; 589 644 } … … 594 649 if (used[pixel]){ 595 650 fdum=(10*GenOff->Rndm()); 596 for(j=0;j<(Int_t) SLICES_MFADC;j++)651 for(j=0;j<(Int_t) fSlices_mFadc;j++) 597 652 sig[pixel][j]+=fdum; 598 653 } … … 607 662 for(i=0;i<numpix;i++){ 608 663 if (used[i]){ 609 for(j=0;j<(Int_t) SLICES_MFADC;j++)664 for(j=0;j<(Int_t) fSlices_mFadc;j++) 610 665 sig[i][j]+=offset; 611 666 } … … 615 670 616 671 if (used[pixel]){ 617 for(j=0;j<(Int_t) SLICES_MFADC;j++)672 for(j=0;j<(Int_t) fSlices_mFadc;j++) 618 673 sig[pixel][j]+=offset; 619 674 } … … 632 687 <<endl; 633 688 634 for (i=0;i<(UInt_t ( SLICES_MFADC))*1001;i++){689 for (i=0;i<(UInt_t (fSlices_mFadc))*1001;i++){ 635 690 noise[i]=GenElec->Gaus(0., value1 ); 636 691 noise_outer[i]=GenElec->Gaus(0., value2 ); … … 656 711 // 657 712 658 startslice=GenElec->Integer(((Int_t) SLICES_MFADC)*1000);713 startslice=GenElec->Integer(((Int_t)fSlices_mFadc)*1000); 659 714 660 715 if ( used[i] == FALSE ) … … 664 719 memcpy( (Float_t*)&sig[i][0], 665 720 (Float_t*)&noise[startslice], 666 ((Int_t) SLICES_MFADC)*sizeof(Float_t));721 ((Int_t) fSlices_mFadc)*sizeof(Float_t)); 667 722 else 668 723 memcpy( (Float_t*)&sig[i][0], 669 724 (Float_t*)&noise_outer[startslice], 670 ((Int_t) SLICES_MFADC)*sizeof(Float_t));725 ((Int_t) fSlices_mFadc)*sizeof(Float_t)); 671 726 } 672 727 … … 677 732 { 678 733 if (i < fInnerPixelsNum) 679 for ( Int_t is=0 ; is< (Int_t) SLICES_MFADC; is++ )734 for ( Int_t is=0 ; is< (Int_t)fSlices_mFadc ; is++ ) 680 735 sig[i][is] += noise[startslice+is]; 681 736 else 682 for ( Int_t is=0 ; is< (Int_t) SLICES_MFADC; is++ )737 for ( Int_t is=0 ; is< (Int_t)fSlices_mFadc ; is++ ) 683 738 sig[i][is] += noise_outer[startslice+is]; 684 739 } … … 694 749 <<endl; 695 750 696 for (i=0;i<UInt_t( SLICES_MFADC*1001);i++){751 for (i=0;i<UInt_t(fSlices_mFadc*1001);i++){ 697 752 xrdm=GenElec->Gaus(0., value); 698 753 digital_noise[i]=(xrdm>0?Int_t(xrdm+0.5):Int_t(xrdm-0.5)); … … 717 772 continue; 718 773 719 startslice=GenElec->Integer((Int_t) SLICES_MFADC*999);774 startslice=GenElec->Integer((Int_t) fSlices_mFadc*999); 720 775 // 721 776 // Then the noise is introduced for each time slice 722 777 // 723 for ( Int_t is =0 ; is< FADC_SLICES; is++ )778 for ( Int_t is = 0 ; is < fFadcSlices; is++ ) 724 779 { 725 780 output[i][is] += digital_noise[startslice+is]; 726 output_lowgain[i][is] += digital_noise[startslice+ FADC_SLICES+is];781 output_lowgain[i][is] += digital_noise[startslice+fFadcSlices+is]; 727 782 } 728 783 } … … 738 793 printf ("Pid %3d", ip ) ; 739 794 740 for ( Int_t is=0 ; is < (Int_t) SLICES_MFADC; is++ ) {795 for ( Int_t is=0 ; is < (Int_t)fSlices_mFadc; is++ ) { 741 796 742 797 if ( sig[ip][is] > 0. ) { … … 776 831 Int_t iFirstSlice ; 777 832 778 iFirstSlice = (Int_t) ( t / WIDTH_FADC_TIMESLICE) ;833 iFirstSlice = (Int_t) ( t * fFadcSlicesPerNanosec ) ; 779 834 780 835 for ( Int_t ip=0; ip<numpix; ip++ ) { … … 799 854 // puts the standard response function into the array resp 800 855 801 for ( Int_t i=0; i< RESPONSE_SLICES; i++ ) { 802 803 resp[i] = sing_resp[i] ; 804 } 856 for ( Int_t i=0; i< fResponseSlicesFadc; i++ ) 857 resp[i] = sing_resp[i]; 858 805 859 } 806 860 … … 841 895 // Get at random a point in the FADC presimulated digital noise: 842 896 // 843 startslice=GenElec->Integer((Int_t) SLICES_MFADC*999);897 startslice=GenElec->Integer((Int_t) fSlices_mFadc*999); 844 898 845 899 for ( Int_t is=0; is < n_slices ; is++ ) … … 875 929 // We had 0.5 for the correct rounding: 876 930 // 877 iFirstSlice = (Int_t) ( 0.5 + time / WIDTH_FADC_TIMESLICE ) ; 878 879 880 for ( Int_t ip=0; ip<numpix; ip++ ) 931 iFirstSlice = (Int_t) ( 0.5 + time * fFadcSlicesPerNanosec ) ; 932 933 for ( Int_t ip = 0; ip < numpix; ip++ ) 881 934 { 882 935 … … 887 940 // it anyway! 888 941 { 889 for ( Int_t i=0 ; i < FADC_SLICES; i++ )942 for ( Int_t i=0 ; i < fFadcSlices ; i++ ) 890 943 { 891 944 output[ip][i]= pedestal[ip]; … … 896 949 897 950 i=0; 898 for ( Int_t is =iFirstSlice ; is < (iFirstSlice+FADC_SLICES); is++ )951 for ( Int_t is = iFirstSlice; is < (iFirstSlice+fFadcSlices); is++ ) 899 952 { 900 if (is < (Int_t) SLICES_MFADC)953 if (is < (Int_t)fSlices_mFadc) 901 954 { 902 955 output[ip][i] = sig[ip][is]; … … 948 1001 sprintf (name, "fadc signal %d", i ) ; 949 1002 950 hist = new TH1F(dumm, name, (Int_t) SLICES_MFADC, fadc_time_offset, TOTAL_TRIGGER_TIME+fadc_time_offset);1003 hist = new TH1F(dumm, name, (Int_t)fSlices_mFadc, fadc_time_offset, TOTAL_TRIGGER_TIME+fadc_time_offset); 951 1004 // 952 1005 // fill the histogram 953 1006 // 954 1007 955 for (Int_t ibin =1; ibin <=(Int_t)SLICES_MFADC; ibin++) {956 hist->SetBinContent (ibin, sig[i][ibin-1]) 957 } 1008 for (Int_t ibin = 1; ibin <= (Int_t)fSlices_mFadc; ibin++) 1009 hist->SetBinContent (ibin, sig[i][ibin-1]); 1010 958 1011 959 1012 // hist->SetMaximum( 5.); -
trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.hxx
r5099 r5248 56 56 Float_t pedestal[CAMERA_PIXELS] ; // Pedestal of FADCs 57 57 58 Float_t sig[CAMERA_PIXELS][(Int_t) SLICES_MFADC] ; // the analog signal for pixels, in bins of width 59 // equal to the FADC slice: 50/15 ns, but with a 60 // total of SLICES_MFADC (=48 now) bins. 61 Float_t noise[((Int_t) SLICES_MFADC)*1001]; 62 Float_t noise_outer[((Int_t) SLICES_MFADC)*1001]; 63 Int_t digital_noise[((Int_t) SLICES_MFADC)*1001]; 64 65 Float_t output[CAMERA_PIXELS][FADC_SLICES]; // the analog signal for pixels that is read after a trigger 66 // occurs (high gain). Only 15 (=FADC_SLICES) bins 67 68 Float_t output_lowgain[CAMERA_PIXELS][FADC_SLICES]; // analog signal, low gain. 58 Int_t fSlices_mFadc; // Number of simulated FADC slices. Larger than the actual number of slices 59 // that will be written, since we have to account for possible delays in the 60 // trigger 61 62 Int_t fResponseSlicesFadc; 63 64 // 65 // Float_t sig[CAMERA_PIXELS][] ; 66 // the analog signal for pixels, in bins of width 67 // equal to the FADC slice: (default 50/15 ns), but with a 68 // total of fSlices_mFadc bins (default 48). 69 // 70 Float_t *sig[CAMERA_PIXELS]; 71 72 Float_t *noise; 73 Float_t *noise_outer; 74 Float_t *digital_noise; 75 76 Float_t *output[CAMERA_PIXELS]; // the analog signal for pixels that is read after a trigger 77 // occurs (high gain). 78 79 Float_t *output_lowgain[CAMERA_PIXELS]; // analog signal, low gain. 69 80 70 81 Float_t high2low_gain; 82 71 83 // 72 84 // first the data for the response function 73 85 // 74 Int_t shape_resp ; // index shape of the phe_response function 75 // = 0 --> Gaussian 76 // = 1 --> Pulpo set-up 77 Float_t fwhm_resp ; // fwhm of the phe_response function (in ns) 78 Float_t integ_resp ; // area below curve of the phe_response function (in counts * ns) 79 Float_t sing_resp[ RESPONSE_SLICES_MFADC ] ; // the shape of the phe_response function 86 Int_t shape_resp; // index shape of the phe_response function 87 // = 0 --> Gaussian 88 // = 1 --> Pulpo set-up 89 Float_t fwhm_resp; // fwhm of the phe_response function (in ns) 90 Float_t integ_resp; // area below curve of the phe_response function (in counts * ns) 91 Float_t *sing_resp; // the shape of the phe_response function 92 93 Float_t fFadcSlicesPerNanosec; // Number of FADC slices per nanosecond, that is, the 94 // sampling frequency of the FADC. 95 96 Int_t fFadcSlices; // Number of FADC slices that will be written on the output 97 // file (same number for high and low gain) 80 98 81 99 // 82 100 // We may end up with a different reponse for the outer pixels 83 101 // 84 Int_t shape_resp_outer ; // index shape of the phe_response function 85 // = 0 --> Gaussian 86 // = 1 --> Pulpo set-up 87 Float_t fwhm_resp_outer ; // fwhm of the phe_response function (in ns) 88 Float_t integ_resp_outer ; // area below curve of the phe_response function (in counts * ns) 89 Float_t sing_resp_outer[ RESPONSE_SLICES_MFADC ] ; // the shape of the phe_response function 102 Int_t shape_resp_outer ; // index shape of the phe_response function 103 // = 0 --> Gaussian 104 // = 1 --> Pulpo set-up 105 Float_t fwhm_resp_outer ; // fwhm of the phe_response function (in ns) 106 Float_t integ_resp_outer; // area below curve of the phe_response function (in counts * ns) 107 Float_t *sing_resp_outer; // the shape of the phe_response function 108 109 90 110 // 91 111 // RandomGenerator for the Electonic Noise … … 98 118 // in the trigger pixels. 99 119 100 101 120 public: 102 121 103 MFadc(Int_t pix=577, 104 Int_t shape=0, 105 Float_t ampl=MFADC_RESPONSE_INTEGRAL, 106 Float_t fwhm=MFADC_RESPONSE_FWHM, 107 Int_t shapeout=0, 108 Float_t amplout=MFADC_RESPONSE_INTEGRAL, 109 Float_t fwhmout=MFADC_RESPONSE_FWHM, 110 Float_t trig_delay=0.) ; 122 MFadc(Int_t pix = 577, 123 Int_t shape = 0, 124 Float_t ampl = MFADC_RESPONSE_INTEGRAL, 125 Float_t fwhm = MFADC_RESPONSE_FWHM, 126 Int_t shapeout = 0, 127 Float_t amplout = MFADC_RESPONSE_INTEGRAL, 128 Float_t fwhmout = MFADC_RESPONSE_FWHM, 129 Float_t trig_delay = 0., 130 Float_t fadc_slices_per_ns = FADC_SLICES_PER_NSEC, 131 Int_t fadc_slices_written = FADC_SLICES); 111 132 112 133 void SetSeed(UInt_t seed) {GenElec->SetSeed(seed);} … … 120 141 void FillOuter( Int_t, Float_t, Float_t ) ; 121 142 122 void Set( Int_t iPix, Float_t res[(Int_t) SLICES_MFADC]); 123 124 void AddSignal( Int_t iPix, Float_t res[(Int_t) SLICES_MFADC]); 143 void Set( Int_t iPix, Float_t *res); 144 void AddSignal( Int_t iPix, Float_t *res); 125 145 126 146 void SetPedestals( Int_t ped); … … 185 205 void SetHigh2LowGain(Float_t h2l) {high2low_gain=h2l;} 186 206 187 Float_t GetShape() {207 Int_t GetShape() { 188 208 return shape_resp; 189 209 } … … 205 225 } 206 226 227 Float_t GetFadcSlicesPerNanosec() { 228 return fFadcSlicesPerNanosec; 229 } 230 231 Int_t GetResponseSlicesFadc() { 232 return fResponseSlicesFadc; 233 } 234 207 235 Bool_t IsPixelUsed(UInt_t p){ 208 236 return used[p]; -
trunk/MagicSoft/Simulation/Detector/include-MLons/MLons.cxx
r5103 r5248 3 3 using namespace std; 4 4 5 MLons::MLons(){ 5 MLons::MLons() 6 { 6 7 //----------------------------------------------------------------- 7 8 // … … 9 10 // 10 11 11 fTrigShape = 0 .0;12 fTrigShape = 0; 12 13 fAmplTrig = 1.0; 13 14 fFwhmTrig = 2.0; 14 15 fFadcShape = 0.0; 15 fFadcSlicesPerNanosec = FADC_SLICES_PER_NSEC; 16 17 fFadcShape = 0; 16 18 fIntegFadc = 1.0; 17 19 fFwhmFadc = 2.0; 18 20 19 RandomNumber = new TRandom() 21 RandomNumber = new TRandom(); 20 22 RandomNumber -> SetSeed(0); 21 23 22 24 } 23 25 24 MLons::MLons(Float_t in_shapeT, Float_t in_amplT, Float_t in_FwhmT, 25 Float_t in_shapeF, Float_t in_integF, Float_t in_FwhmF){ 26 MLons::MLons(Int_t in_shapeT, Float_t in_amplT, Float_t in_FwhmT, 27 Int_t in_shapeF, Float_t in_integF, Float_t in_FwhmF, 28 Float_t in_Fadc_Slices_per_ns) 29 { 26 30 //-------------------------------------------------------------------- 27 31 // … … 37 41 fFwhmFadc = in_FwhmF; 38 42 43 fFadcSlicesPerNanosec = in_Fadc_Slices_per_ns; 44 45 MSLStored = new MStarLight; 46 39 47 RandomNumber = new TRandom() ; 40 48 RandomNumber -> SetSeed(0); 41 49 } 42 50 43 void MLons::Reset() { 51 void MLons::Reset() 52 { 44 53 //----------------------------------------------------------------- 45 54 // … … 47 56 // 48 57 49 fTrigShape = 0 .;50 fAmplTrig = 0. 51 fFwhmTrig = 0. 52 53 fFadcShape = 0 .;54 fIntegFadc = 0.;55 fFwhmFadc = 0. 56 57 MSLStored .Reset();58 fTrigShape = 0; 59 fAmplTrig = 0.; 60 fFwhmTrig = 0.; 61 62 fFadcShape = 0; 63 fIntegFadc = 0.; 64 fFwhmFadc = 0.; 65 66 MSLStored->Reset(); 58 67 59 68 } … … 110 119 } 111 120 112 void MLons::ReadBinaryMStarLight(char *filename) {113 114 MSLStored .ReadBinary(filename);115 116 } 117 118 Int_t MLons::CheckTrig(){121 void MLons::ReadBinaryMStarLight(char *filename) 122 { 123 MSLStored->ReadBinary(filename); 124 } 125 126 Int_t MLons::CheckTrig() 127 { 119 128 //-------------------------------------------------------------------- 120 129 // … … 122 131 // 123 132 124 if ( fAmplTrig == MSLStored .GetAmplTrig() &&125 fFwhmTrig == MSLStored .GetFwhmTrig())133 if ( fAmplTrig == MSLStored->GetAmplTrig() && 134 fFwhmTrig == MSLStored->GetFwhmTrig()) 126 135 return 1; 127 136 137 cout << "1 phe- pulse amplitudes for trigger (mV): " << fAmplTrig << " " 138 << MSLStored->GetAmplTrig() << endl; 139 cout << "1 phe- pulse FWHM for trigger (ns): " << fFwhmTrig << " " 140 << MSLStored->GetFwhmTrig() << endl; 141 128 142 return 0; 129 143 } 130 144 131 Int_t MLons::CheckFADC(){ 145 Int_t MLons::CheckFADC() 146 { 132 147 //-------------------------------------------------------------------- 133 148 // … … 135 150 // 136 151 137 if ( fIntegFadc == MSLStored.GetIntegFadc() && 138 fFwhmFadc == MSLStored.GetFwhmFadc() && 139 fFadcShape == MSLStored.GetShapeFadc()) 152 if ( fIntegFadc == MSLStored->GetIntegFadc() && 153 fFwhmFadc == MSLStored->GetFwhmFadc() && 154 fFadcShape == MSLStored->GetShapeFadc() && 155 fFadcSlicesPerNanosec == MSLStored->GetFadcSlicesPerNanosec() ) 140 156 return 1; 141 157 158 cout << "1 phe- FADC pulse shape : " << fFadcShape << " " 159 << MSLStored->GetShapeFadc() << endl; 160 cout << "1 phe- FADC pulse integral (counts) : " << fIntegFadc << " " 161 << MSLStored->GetIntegFadc() << endl; 162 cout << "1 phe- FADC pulse FWHM (ns) : " << fFwhmFadc << " " 163 << MSLStored->GetFwhmFadc() << endl; 164 cout << "FADC sampling frequencies (GHz) : " << fFadcSlicesPerNanosec << " " 165 << MSLStored->GetFadcSlicesPerNanosec() << endl; 166 142 167 return 0; 143 168 } 144 169 145 170 Int_t MLons::GetResponse(Float_t in_br, Float_t in_pre, 146 Float_t *out_tr, Float_t *out_Fr){ 171 Float_t *out_tr, Float_t *out_Fr) 172 { 147 173 //------------------------------------------------------------------------- 148 174 // … … 154 180 Char_t cstoredbright[10]; 155 181 156 Int_t i;157 182 Int_t bin; 158 Float_t start_bin; 159 Float_t time; 160 183 Float_t start_time; 184 185 186 // 161 187 // The following code line commented means that the simulation will crash if 162 188 // some pixel ask for more lons than what we have in the database. 163 189 // The following code line uncommented would mean that the simulation does 164 // not crash if a pixel ask for more than it is simulated but would 165 // assign to it lees lons. 166 if (in_br>49.9) in_br=49.9; // To avoid error for high required brightness 167 // It has to be improved 190 // not crash if a pixel ask for more than it is simulated but would 191 // assign to it less lons. 192 // I think this is unnecessary now. AM 5/10/2004 193 // if (in_br>49.9) in_br=49.9; // To avoid error for high required brightness 194 // // It has to be improved 195 // 196 168 197 169 198 // Check if the the brightness is the same than the last time. 170 // NOTE: Same means, the s mae inside the required precision!!!171 172 if(in_br< 1.0){199 // NOTE: Same means, the same inside the required precision!!! 200 201 if(in_br<=1.0){ 173 202 sprintf(cbright,"%4.2f",in_br); 174 sprintf(cstoredbright,"%4.2f",MSLStored .GetBrightness());203 sprintf(cstoredbright,"%4.2f",MSLStored->GetBrightness()); 175 204 } 176 205 else{ 177 206 sprintf(cbright,"%3.1f",in_br); 178 sprintf(cstoredbright,"%3.1f",MSLStored .GetBrightness());207 sprintf(cstoredbright,"%3.1f",MSLStored->GetBrightness()); 179 208 } 180 if (strcmp(cbright, cstoredbright)){ 181 182 // Building the filename 183 // Note: it would be nice to get an algorithm that gets the name of 184 // files it needs to get brightness as a function of precison(in_pre), 185 // brightnes (in_br) and the Star_files that are in the "Path" directory. 186 187 strcpy(filename_slt, & path[0]); 188 strcat(filename_slt, "Brightness"); 189 strcat(filename_slt, & cbright[0]); 209 210 if (strcmp(cbright, cstoredbright)) 211 { 212 // Building the filename 213 // Note: it would be nice to get an algorithm that gets the name of 214 // files it needs to get brightness as a function of precison(in_pre), 215 // brightnes (in_br) and the Star_files that are in the "Path" directory. 216 217 strcpy(filename_slt, & path[0]); 218 strcat(filename_slt, "Brightness"); 219 strcat(filename_slt, & cbright[0]); 190 220 191 strcat(filename_slt, ".slt");221 strcat(filename_slt, ".slt"); 192 222 193 // If brightness is different it check if the new file has the 194 // required parameters. 195 // Note: I could be faster to store the whole trigger and fadc 196 // response and use it while brightness does not change. Then the 197 // root file should be open and close here. 198 199 ReadBinaryMStarLight( & filename_slt[0]); 200 201 if (!(CheckTrig() && CheckFADC())) { 202 cout<<"ERROR: The Database for light from Night Sky Background is wrong"<<endl<<" Make sure that you generated the database with the same shape for Fadc and trigger taht you are asking now."<<endl; 203 return 0; 223 // If brightness is different it check if the new file has the 224 // required parameters. 225 // Note: I could be faster to store the whole trigger and fadc 226 // response and use it while brightness does not change. Then the 227 // root file should be open and close here. 228 229 MSLStored->ReadBinary(filename_slt); 230 231 if (!(CheckTrig() && CheckFADC())) 232 { 233 cout << "ERROR: The Database for light from Night Sky Background is wrong"<<endl; 234 cout << " Make sure that you generated the database with the same shape" << endl; 235 cout << " for Fadc and trigger that you are asking now."<<endl; 236 return 0; 237 } 238 MSLStored->SetBrightness(in_br); 239 204 240 } 205 MSLStored.SetBrightness(in_br);206 207 }208 241 209 242 // Random number that decides the set of bins that the program will get 210 start_ bin=RandomNumber->Uniform(1.0e4);243 start_time = RandomNumber->Uniform(TIMERANGE); 211 244 212 245 // Filling trigger response 213 246 214 bin=(Int_t)(start_bin*4); 215 216 for (i=0;i<TRIGGER_TIME_SLICES;i++){ 217 218 time=((float)i)/SLICES_PER_NSEC; 219 220 if (time>(bin-start_bin*4.0)/4.0) bin++; 221 222 if (bin>=TRIGBINS) bin=bin-TRIGBINS; 223 224 out_tr[i]=MSLStored.GetTrig(bin); 225 } 247 bin = (Int_t)(start_time*TRIG_SLICES_PER_NSEC); 248 249 250 if (bin+TRIGGER_TIME_SLICES > MSLStored->GetBinsTrig()) 251 { 252 memcpy (out_tr, MSLStored->GetTrigPointer(bin), 253 (UInt_t) (MSLStored->GetBinsTrig()-bin)*sizeof(Float_t)); 254 memcpy (out_tr, MSLStored->GetTrigPointer(0), 255 (UInt_t) (bin+TRIGGER_TIME_SLICES-MSLStored->GetBinsTrig())*sizeof(Float_t)); 256 } 257 else 258 memcpy (out_tr, MSLStored->GetTrigPointer(bin), 259 (UInt_t) TRIGGER_TIME_SLICES*sizeof(Float_t)); 260 226 261 227 262 // Filling fadc response 228 263 229 bin=(Int_t) (start_bin*0.3); 230 231 for (i=0;i<(Int_t) SLICES_MFADC;i++){ 232 233 time=((float)i)*WIDTH_FADC_TIMESLICE; 234 235 if (time>(bin-start_bin*0.3)/0.3) bin++; 236 237 if (bin>=FADCBINS) bin=bin-FADCBINS; 238 239 out_Fr[i]=MSLStored.GetFadc(bin); 240 } 264 // Start bin in the NSB database: 265 bin = (Int_t) (start_time*MSLStored->GetBinsFadc()/MSLStored->GetTimeRange()); 266 267 // If we go over the end of the database, continue at the begining of it: 268 if (bin + (Int_t)(TOTAL_TRIGGER_TIME*fFadcSlicesPerNanosec) > MSLStored->GetBinsFadc()) 269 { 270 memcpy (out_Fr, MSLStored->GetFadcPointer(bin), 271 (Int_t)(MSLStored->GetBinsFadc()-bin)*sizeof(Float_t)); 272 273 memcpy (out_Fr, MSLStored->GetFadcPointer(0), 274 (Int_t)(bin + TOTAL_TRIGGER_TIME*fFadcSlicesPerNanosec - 275 MSLStored->GetBinsFadc())*sizeof(Float_t)); 276 } 277 else 278 memcpy (out_Fr, MSLStored->GetFadcPointer(bin), 279 (Int_t)(TOTAL_TRIGGER_TIME*fFadcSlicesPerNanosec*sizeof(Float_t))); 241 280 242 281 return 1; -
trunk/MagicSoft/Simulation/Detector/include-MLons/MLons.hxx
r5103 r5248 33 33 // 34 34 35 class MLons { 35 class MLons 36 { 36 37 37 38 private: 38 39 39 Char_t path[256] ;// Location of StarLight files40 Char_t path[256]; // Location of StarLight files 40 41 41 MStarLight MSLStored ; // MStarLight in memmory42 MStarLight *MSLStored; // MStarLight in memory 42 43 43 Float_t fTrigShape ;// a number that indicate the shape type of44 45 46 Float_t fAmplTrig ;// the amplitude of the trigger in mV47 Float_t fFwhmTrig ;// the width of the signal in nsec44 Int_t fTrigShape; // a number that indicate the shape type of 45 // the signal 46 // = 0 --> a gaussian 47 Float_t fAmplTrig; // the amplitude of the trigger in mV 48 Float_t fFwhmTrig; // the width of the signal in nsec 48 49 49 Float_t fFadcShape ;// a number that indicate the shape type of50 51 52 Float_t fIntegFadc ;// the integral of the single phe response53 54 Float_t fFwhmFadc ;// the width of the signal in nsec50 Int_t fFadcShape; // a number that indicate the shape type of 51 // the signal 52 // = 0 --> a gaussian 53 Float_t fIntegFadc; // the integral of the single phe response 54 // in the FADC (in FADC counts) 55 Float_t fFwhmFadc; // the width of the signal in nsec 55 56 56 TRandom *RandomNumber; // RandomGenerator 57 Float_t fFadcSlicesPerNanosec; // The sampling frequency (GHz) of the FADC 58 59 TRandom *RandomNumber; // RandomGenerator 57 60 58 61 public: … … 60 63 MLons() ; 61 64 62 MLons(Float_t in_shapeT, Float_t in_amplT, Float_t in_FwhmT, 63 Float_t in_shapeF, Float_t in_integF, Float_t in_FwhmF) ; 65 MLons(Int_t in_shapeT, Float_t in_amplT, Float_t in_FwhmT, 66 Int_t in_shapeF, Float_t in_integF, Float_t in_FwhmF, 67 Float_t in_Fadc_Slices_per_ns); 64 68 65 69 void Reset() ; … … 78 82 Float_t GetIntegFadc() ; 79 83 Float_t GetFwhmFadc() ; 84 Float_t GetFadcSlicesPerNanosec() {return fFadcSlicesPerNanosec;} 80 85 81 86 void GetPath(Char_t *out); -
trunk/MagicSoft/Simulation/Detector/include-MTrigger/MTrigger.cxx
r5104 r5248 206 206 x0 = 3*sigma ; 207 207 208 for (i=0; i< RESPONSE_SLICES ; i++ ) {209 210 x = i * (1./((Float_t) SLICES_PER_NSEC))211 + (1./( 2 * (Float_t) SLICES_PER_NSEC )) ;208 for (i=0; i< RESPONSE_SLICES_TRIG ; i++ ) { 209 210 x = i * (1./((Float_t)TRIG_SLICES_PER_NSEC)) 211 + (1./( 2 * (Float_t)TRIG_SLICES_PER_NSEC )) ; 212 212 213 sing_resp[i] = 213 sing_resp[i] = (Float_t) 214 214 ampl_resp * expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ; 215 215 … … 224 224 Int_t imax = 0 ; 225 225 Float_t max = 0. ; 226 for (i=0; i< RESPONSE_SLICES ; i++ ) {226 for (i=0; i< RESPONSE_SLICES_TRIG ; i++ ) { 227 227 if ( sing_resp[i] > max ) { 228 228 imax = i ; … … 231 231 } 232 232 233 peak_time = ( (Float_t) imax ) / ( (Float_t) SLICES_PER_NSEC ) ;233 peak_time = ( (Float_t) imax ) / ( (Float_t) TRIG_SLICES_PER_NSEC ) ; 234 234 235 235 … … 357 357 358 358 for ( i = 0 ; i < 5 ; i++) { 359 SlicesFirst[i] = -50;360 SlicesSecond[i] = -50;359 SlicesFirst[i] = 0; 360 SlicesSecond[i] = 0; 361 361 PixelsFirst[i] = -1; 362 362 PixelsSecond[i] = -1; … … 454 454 x0 = 3*sigma ; 455 455 456 for (i=0; i< RESPONSE_SLICES ; i++ ) {457 458 x = i * (1./((Float_t) SLICES_PER_NSEC))459 + (1./( 2 * (Float_t) SLICES_PER_NSEC )) ;456 for (i=0; i< RESPONSE_SLICES_TRIG ; i++ ) { 457 458 x = i * (1./((Float_t)TRIG_SLICES_PER_NSEC)) 459 + (1./( 2 * (Float_t)TRIG_SLICES_PER_NSEC )) ; 460 460 461 sing_resp[i] = 461 sing_resp[i] = (Float_t) 462 462 ampl_resp * expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ; 463 463 … … 472 472 Int_t imax = 0 ; 473 473 Float_t max = 0. ; 474 for (i=0; i< RESPONSE_SLICES ; i++ ) {474 for (i=0; i< RESPONSE_SLICES_TRIG ; i++ ) { 475 475 if ( sing_resp[i] > max ) { 476 476 imax = i ; … … 479 479 } 480 480 481 peak_time = ( (Float_t) imax ) / ( (Float_t) SLICES_PER_NSEC ) ;481 peak_time = ( (Float_t) imax ) / ( (Float_t) TRIG_SLICES_PER_NSEC ) ; 482 482 483 483 // … … 588 588 589 589 for ( i = 0 ; i < 5 ; i++) { 590 SlicesFirst[i] = -50 ;591 SlicesSecond[i] = -50 ;590 SlicesFirst[i] = 0 ; 591 SlicesSecond[i] = 0 ; 592 592 PixelsFirst[i] = -1; 593 593 PixelsSecond[i] = -1; … … 683 683 x0 = 3*sigma ; 684 684 685 for (i=0; i< RESPONSE_SLICES ; i++ ) {686 687 x = i * (1./((Float_t) SLICES_PER_NSEC))688 + (1./( 2 * (Float_t) SLICES_PER_NSEC )) ;685 for (i=0; i< RESPONSE_SLICES_TRIG ; i++ ) { 686 687 x = i * (1./((Float_t)TRIG_SLICES_PER_NSEC)) 688 + (1./( 2 * (Float_t)TRIG_SLICES_PER_NSEC )) ; 689 689 690 sing_resp[i] = 690 sing_resp[i] = (Float_t) 691 691 ampl_resp * expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ; 692 692 … … 701 701 Int_t imax = 0 ; 702 702 Float_t max = 0. ; 703 for (i=0; i< RESPONSE_SLICES ; i++ ) {703 for (i=0; i< RESPONSE_SLICES_TRIG ; i++ ) { 704 704 if ( sing_resp[i] > max ) { 705 705 imax = i ; … … 708 708 } 709 709 710 peak_time = ( (Float_t) imax ) / ( (Float_t) SLICES_PER_NSEC ) ;710 peak_time = ( (Float_t) imax ) / ( (Float_t) TRIG_SLICES_PER_NSEC ) ; 711 711 712 712 // … … 772 772 773 773 for ( i = 0 ; i < 5 ; i++) { 774 SlicesFirst[i] = -50 ;775 SlicesSecond[i] = -50 ;774 SlicesFirst[i] = 0 ; 775 SlicesSecond[i] = 0 ; 776 776 PixelsFirst[i] = -1; 777 777 PixelsSecond[i] = -1; … … 843 843 844 844 for ( i = 0 ; i < 5 ; i++) { 845 SlicesFirst[i] = -50 ;845 SlicesFirst[i] = 0 ; 846 846 PixelsFirst[i] = -1; 847 847 } … … 872 872 // 873 873 // Fills the information of one single Phe electron that 874 // comes from the shower874 // comes from the NSB 875 875 // 876 876 … … 892 892 // 893 893 // Fills the information of one single Phe electron that 894 // comes from the shower 895 // 894 // comes from a star 896 895 897 896 // … … 969 968 // 970 969 971 Int_t ichan = (Int_t) ( time * ((Float_t) SLICES_PER_NSEC) ) ;970 Int_t ichan = (Int_t) ( time * ((Float_t) TRIG_SLICES_PER_NSEC) ) ; 972 971 973 972 // … … 975 974 // 976 975 977 for ( i = 0 ; i<RESPONSE_SLICES ; i++ ) {976 for ( i = 0 ; i<RESPONSE_SLICES_TRIG; i++ ) { 978 977 979 978 if ( (ichan+i) >= 0 && … … 1132 1131 x0 = 3*sigma ; 1133 1132 1134 for (i=0; i< RESPONSE_SLICES ; i++ ) {1135 1136 x = i * (1./((Float_t) SLICES_PER_NSEC))1137 + (1./( 2 * (Float_t) SLICES_PER_NSEC )) ;1133 for (i=0; i< RESPONSE_SLICES_TRIG ; i++ ) { 1134 1135 x = i * (1./((Float_t)TRIG_SLICES_PER_NSEC)) 1136 + (1./( 2 * (Float_t)TRIG_SLICES_PER_NSEC )) ; 1138 1137 1139 sing_resp[i] = 1138 sing_resp[i] = (Float_t) 1140 1139 ampl_resp * expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ; 1141 1140 … … 1244 1243 // puts the standard response function into the array resp 1245 1244 1246 for ( Int_t i=0; i< RESPONSE_SLICES ; i++ ) {1245 for ( Int_t i=0; i< RESPONSE_SLICES_TRIG; i++ ) { 1247 1246 1248 1247 resp[i] = sing_resp[i] ; … … 1288 1287 1289 1288 1290 Int_t jmax = (Int_t) (gate_leng * SLICES_PER_NSEC ) ;1289 Int_t jmax = (Int_t) (gate_leng * TRIG_SLICES_PER_NSEC ) ; 1291 1290 1292 1291 // … … 1572 1571 if (SlicesZero[iSli]){ 1573 1572 // 1574 // Loop over trigger cells. It is topology anal isy,1575 // therefore it is ke ephere after multiplicity and1573 // Loop over trigger cells. It is topology analysis, 1574 // therefore it is kept here after multiplicity and 1576 1575 // threshold checks. 1577 1576 // … … 1645 1644 SlicesFirst[nFirst++] = iSli ; // We save time when it triggers 1646 1645 iReturn++ ; 1647 iSli+=( 50*SLICES_PER_NSEC); // We skip the following 50 ns (dead time)1646 iSli+=(LEVEL1_DEAD_TIME*TRIG_SLICES_PER_NSEC); // We skip the following 50 ns (dead time) 1648 1647 iCell=TRIGGER_CELLS; // We skip the remaining trigger cells 1649 1648 break ; … … 1675 1674 SlicesFirst[nFirst++] = iSli ; // We save when it triggers 1676 1675 iReturn++ ; 1677 iSli+=( 50*SLICES_PER_NSEC); // We skip the following 50 ns (dead time)1676 iSli+=(LEVEL1_DEAD_TIME*TRIG_SLICES_PER_NSEC); // We skip the following 50 ns (dead time) 1678 1677 iCell=TRIGGER_CELLS; // We skip the remaining trigger cells 1679 1678 break ; … … 1768 1767 SlicesFirst[nFirst++] = iSli ; // We save time when it triggers 1769 1768 iReturn++ ; 1770 iSli+=( 50*SLICES_PER_NSEC); // We skip the following 50 ns (dead time)1769 iSli+=(LEVEL1_DEAD_TIME*TRIG_SLICES_PER_NSEC); // We skip the following 50 ns (dead time) 1771 1770 iCell=TRIGGER_CELLS; // We skip the remaining trigger cells 1772 1771 break ; … … 1863 1862 // It gives the time for the il trigger at first level 1864 1863 1865 return((Float_t) ((Float_t) SlicesFirst[il]/((Float_t) SLICES_PER_NSEC)));1864 return((Float_t) ((Float_t) SlicesFirst[il]/((Float_t) TRIG_SLICES_PER_NSEC))); 1866 1865 } 1867 1866 … … 1885 1884 1886 1885 // Translation from ns to slices 1887 iNumSli=(int) (overlaping_time* SLICES_PER_NSEC);1886 iNumSli=(int) (overlaping_time*TRIG_SLICES_PER_NSEC); 1888 1887 if (iNumSli<1) iNumSli=1; 1889 1888 … … 1901 1900 1902 1901 } 1903 1904 1905 -
trunk/MagicSoft/Simulation/Detector/include-MTrigger/MTrigger.hxx
r5099 r5248 109 109 // first the data for the response function 110 110 // 111 Float_t fwhm_resp ; // fwhm of the phe_response function 112 Float_t ampl_resp ; // amplitude of the phe_response function (in mV) 113 Float_t sing_resp[ RESPONSE_SLICES ] ; // the shape of the phe_response function 114 Float_t peak_time ; // the time from the start of the response function to the maximum peak 111 Float_t fwhm_resp ; // fwhm of the phe_response function 112 Float_t ampl_resp ; // amplitude of the phe_response function (in mV) 113 Float_t sing_resp[RESPONSE_SLICES_TRIG] ; // the shape of the phe_response function 114 Float_t peak_time ; // the time from the start of the response 115 // function to the maximum peak 115 116 116 117 TH1F *histPmt ;
Note:
See TracChangeset
for help on using the changeset viewer.