| 1 | ////////////////////////////////////////////////////////////////
|
|---|
| 2 | //
|
|---|
| 3 | // MFadc
|
|---|
| 4 | //
|
|---|
| 5 | //
|
|---|
| 6 | #include "MFadc.hxx"
|
|---|
| 7 |
|
|---|
| 8 | #include "MMcEvt.hxx"
|
|---|
| 9 |
|
|---|
| 10 | #include "TROOT.h"
|
|---|
| 11 | #include <TApplication.h>
|
|---|
| 12 | #include <TVirtualX.h>
|
|---|
| 13 | #include <TGClient.h>
|
|---|
| 14 |
|
|---|
| 15 | #include "TH1.h"
|
|---|
| 16 | #include "TObjArray.h"
|
|---|
| 17 |
|
|---|
| 18 | #include "MGFadcSignal.hxx"
|
|---|
| 19 |
|
|---|
| 20 | MFadc::MFadc(Int_t pix, Float_t ampl, Float_t fwhm, Float_t amplout, Float_t fwhmout) {
|
|---|
| 21 | //
|
|---|
| 22 | // Constructor overloaded II
|
|---|
| 23 | //
|
|---|
| 24 | // Input variables:
|
|---|
| 25 | // 1. ampl(out) = integration of the single phe response (outer pixels)
|
|---|
| 26 | // 2. fwhm(out) = width at half high of the single phe
|
|---|
| 27 | // response(outer pixels)
|
|---|
| 28 | //
|
|---|
| 29 | // The procedure is the following:
|
|---|
| 30 | // 1. some parameters of the trigger are set to default.
|
|---|
| 31 | // this parameters of the trigger may be changed
|
|---|
| 32 | // 3. Then the all signals are set to zero
|
|---|
| 33 | numpix=pix;
|
|---|
| 34 |
|
|---|
| 35 | fwhm_resp = fwhm;
|
|---|
| 36 | ampl_resp = ampl;
|
|---|
| 37 | fwhm_resp_outer = fwhmout;
|
|---|
| 38 | ampl_resp_outer = amplout;
|
|---|
| 39 |
|
|---|
| 40 | cout<< "[MFadc] Setting up the MFadc with this values "<< endl ;
|
|---|
| 41 | cout<< "[MFadc] - Inner pixels : "<< endl ;
|
|---|
| 42 | cout<< "[MFadc] Response Are : "<<ampl<<" adc counts"<< endl ;
|
|---|
| 43 | cout<< "[MFadc] Response FWHM : "<<fwhm<<" ns"<< endl ;
|
|---|
| 44 | cout<< "[MFadc] - Outer pixels : "<< endl ;
|
|---|
| 45 | cout<< "[MFadc] Response Are : "<<amplout<<" adc counts"<< endl ;
|
|---|
| 46 | cout<< "[MFadc] Response FWHM : "<<fwhmout<<" ns"<< endl ;
|
|---|
| 47 |
|
|---|
| 48 | //
|
|---|
| 49 | // set up the response shape
|
|---|
| 50 | //
|
|---|
| 51 | Int_t i ;
|
|---|
| 52 |
|
|---|
| 53 | Float_t sigma ;
|
|---|
| 54 | Float_t x, x0 ;
|
|---|
| 55 |
|
|---|
| 56 | sigma = fwhm_resp / 2.35 ;
|
|---|
| 57 | x0 = 3*sigma;
|
|---|
| 58 |
|
|---|
| 59 | Float_t dX, dX2 ;
|
|---|
| 60 |
|
|---|
| 61 | dX = WIDTH_FADC_TIMESLICE / SUBBINS ;
|
|---|
| 62 | dX2 = dX/2. ;
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | for (i=0; i< RESPONSE_SLICES_MFADC ; i++ ) {
|
|---|
| 67 |
|
|---|
| 68 | x = i * dX + dX2 ;
|
|---|
| 69 |
|
|---|
| 70 | //
|
|---|
| 71 | // the value 1/(2*Pi*sigma^2) was introduced to normalize
|
|---|
| 72 | // the area at the input value
|
|---|
| 73 | //
|
|---|
| 74 | sing_resp[i] = ampl_resp / sqrt(2*3.1415926*sigma*sigma)*
|
|---|
| 75 | expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ;
|
|---|
| 76 |
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 | sigma = fwhm_resp_outer / 2.35 ;
|
|---|
| 81 | x0 = 3*sigma ;
|
|---|
| 82 |
|
|---|
| 83 | dX = WIDTH_FADC_TIMESLICE / SUBBINS ;
|
|---|
| 84 | dX2 = dX/2. ;
|
|---|
| 85 |
|
|---|
| 86 | for (i=0; i< RESPONSE_SLICES_MFADC ; i++ ) {
|
|---|
| 87 |
|
|---|
| 88 | x = i * dX + dX2 ;
|
|---|
| 89 |
|
|---|
| 90 | //
|
|---|
| 91 | // the value 1/(2*Pi*sigma^2) was introduced to normalize
|
|---|
| 92 | // the area at the input value
|
|---|
| 93 | //
|
|---|
| 94 | sing_resp_outer[i] = ampl_resp_outer / sqrt(2*3.1415926*sigma*sigma)*
|
|---|
| 95 | expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ;
|
|---|
| 96 |
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | //
|
|---|
| 100 | // init the Random Generator for Electonic Noise
|
|---|
| 101 | //
|
|---|
| 102 |
|
|---|
| 103 | GenElec = new TRandom () ;
|
|---|
| 104 |
|
|---|
| 105 | Reset();
|
|---|
| 106 |
|
|---|
| 107 | //
|
|---|
| 108 | // set all pedestals to 0
|
|---|
| 109 | //
|
|---|
| 110 |
|
|---|
| 111 | for ( i =0 ; i <CAMERA_PIXELS ; i++ ) {
|
|---|
| 112 | pedestal[i] = 0.0 ;
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | cout<<" end of MFadc::MFadc()"<<endl;
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 | void MFadc::Reset() {
|
|---|
| 119 | //
|
|---|
| 120 | // set all values of the signals to zero
|
|---|
| 121 | // set tha values of FADC slices that would be read after trigger to zero
|
|---|
| 122 | //
|
|---|
| 123 | memset(used, 0, CAMERA_PIXELS*sizeof(Bool_t));
|
|---|
| 124 | memset(output, 0, CAMERA_PIXELS*FADC_SLICES*sizeof(UChar_t));
|
|---|
| 125 | memset(output_lowgain, 0, CAMERA_PIXELS*FADC_SLICES*sizeof(UChar_t));
|
|---|
| 126 | }
|
|---|
| 127 | void MFadc::Fill( Int_t iPix, Float_t time,
|
|---|
| 128 | Float_t amplitude, Int_t isinner ) {
|
|---|
| 129 |
|
|---|
| 130 | if(isinner)
|
|---|
| 131 | Fill(iPix, time, amplitude);
|
|---|
| 132 | else
|
|---|
| 133 | FillOuter(iPix, time, amplitude);
|
|---|
| 134 |
|
|---|
| 135 | }
|
|---|
| 136 | void MFadc::Fill( Int_t iPix, Float_t time, Float_t amplitude ) {
|
|---|
| 137 |
|
|---|
| 138 | //
|
|---|
| 139 | // fills the information about one single Phe in the Trigger class
|
|---|
| 140 | //
|
|---|
| 141 | // parameter is the number of the pixel and the time-difference to the
|
|---|
| 142 | // first particle
|
|---|
| 143 | //
|
|---|
| 144 | //
|
|---|
| 145 |
|
|---|
| 146 | Int_t i, ichan, ichanfadc ;
|
|---|
| 147 |
|
|---|
| 148 | //
|
|---|
| 149 | // first we have to check if the pixel iPix is used or not until now
|
|---|
| 150 | // if this is the first use, reset all signal for that pixels
|
|---|
| 151 | //
|
|---|
| 152 | if ( iPix > numpix ) {
|
|---|
| 153 | cout << " WARNING: MFadc::Fill() : iPix greater than Pixels in Camera = "
|
|---|
| 154 | << numpix
|
|---|
| 155 | << endl ;
|
|---|
| 156 | exit(987) ;
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | if ( used[iPix] == FALSE ) {
|
|---|
| 160 | used [iPix] = TRUE ;
|
|---|
| 161 |
|
|---|
| 162 | for (i=0; i < (Int_t) SLICES_MFADC; i++ ) {
|
|---|
| 163 | sig[iPix][i] = 0. ;
|
|---|
| 164 | }
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | //
|
|---|
| 168 | // then select the time slice to use (ican)
|
|---|
| 169 | //
|
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 | if ( time < 0. ) {
|
|---|
| 173 | cout << " WARNING! Fadc::Fill " << time << " below ZERO!! Very strange!!"
|
|---|
| 174 | << endl ;
|
|---|
| 175 | }
|
|---|
| 176 | else if ( time < TOTAL_TRIGGER_TIME ) {
|
|---|
| 177 | //
|
|---|
| 178 | // determine the slices number assuming the WIDTH_RESPONSE_MFADC
|
|---|
| 179 | //
|
|---|
| 180 | ichan = (Int_t) ( time / ((Float_t) WIDTH_RESPONSE_MFADC ));
|
|---|
| 181 |
|
|---|
| 182 | //
|
|---|
| 183 | // putting the response slices in the right sig slices.
|
|---|
| 184 | // Be carefull, because both slices have different widths.
|
|---|
| 185 | //
|
|---|
| 186 |
|
|---|
| 187 | for ( i = 0 ; i<RESPONSE_SLICES; i++ ) {
|
|---|
| 188 | ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ;
|
|---|
| 189 | if ( (ichanfadc) < (Int_t)SLICES_MFADC ) {
|
|---|
| 190 | sig[iPix][ichanfadc] += (amplitude * sing_resp[i] ) ;
|
|---|
| 191 | }
|
|---|
| 192 | }
|
|---|
| 193 | }
|
|---|
| 194 | else {
|
|---|
| 195 | cout << " WARNING! Fadc::Fill " << time << " out of TriggerTimeRange "
|
|---|
| 196 | << TOTAL_TRIGGER_TIME << endl ;
|
|---|
| 197 | }
|
|---|
| 198 |
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|
| 201 | void MFadc::FillOuter( Int_t iPix, Float_t time, Float_t amplitude ) {
|
|---|
| 202 |
|
|---|
| 203 | //
|
|---|
| 204 | // fills the information about one single Phe in the Trigger class
|
|---|
| 205 | // for an outer pixel
|
|---|
| 206 | //
|
|---|
| 207 | // parameter is the number of the pixel and the time-difference to the
|
|---|
| 208 | // first particle
|
|---|
| 209 | //
|
|---|
| 210 | //
|
|---|
| 211 |
|
|---|
| 212 | Int_t i, ichan, ichanfadc ;
|
|---|
| 213 |
|
|---|
| 214 | //
|
|---|
| 215 | // first we have to check if the pixel iPix is used or not until now
|
|---|
| 216 | // if this is the first use, reset all signal for that pixels
|
|---|
| 217 | //
|
|---|
| 218 | if ( iPix > numpix ) {
|
|---|
| 219 | cout << " WARNING: MFadc::FillOuter() : iPix greater than CAMERA_PIXELS"
|
|---|
| 220 | << endl ;
|
|---|
| 221 | exit(987) ;
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | if ( used[iPix] == FALSE ) {
|
|---|
| 225 | used [iPix] = TRUE ;
|
|---|
| 226 |
|
|---|
| 227 | for (i=0; i < (Int_t) SLICES_MFADC; i++ ) {
|
|---|
| 228 | sig[iPix][i] = 0. ;
|
|---|
| 229 | }
|
|---|
| 230 | }
|
|---|
| 231 |
|
|---|
| 232 | //
|
|---|
| 233 | // then select the time slice to use (ican)
|
|---|
| 234 | //
|
|---|
| 235 |
|
|---|
| 236 |
|
|---|
| 237 | if ( time < 0. ) {
|
|---|
| 238 | cout << " WARNING! Fadc::FillOuter " << time << " below ZERO!! Very strange!!"
|
|---|
| 239 | << endl ;
|
|---|
| 240 | }
|
|---|
| 241 | else if ( time < TOTAL_TRIGGER_TIME ) {
|
|---|
| 242 | //
|
|---|
| 243 | // determine the slices number assuming the WIDTH_RESPONSE_MFADC
|
|---|
| 244 | //
|
|---|
| 245 | ichan = (Int_t) ( time / ((Float_t) WIDTH_RESPONSE_MFADC ));
|
|---|
| 246 |
|
|---|
| 247 | //
|
|---|
| 248 | // putting the response slices in the right sig slices.
|
|---|
| 249 | // Be carefull, because both slices have different widths.
|
|---|
| 250 | //
|
|---|
| 251 |
|
|---|
| 252 | for ( i = 0 ; i<RESPONSE_SLICES; i++ ) {
|
|---|
| 253 | ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ;
|
|---|
| 254 | if ( (ichanfadc) < (Int_t)SLICES_MFADC ) {
|
|---|
| 255 | sig[iPix][ichanfadc] += (amplitude * sing_resp_outer[i] ) ;
|
|---|
| 256 | }
|
|---|
| 257 | }
|
|---|
| 258 | }
|
|---|
| 259 | else {
|
|---|
| 260 | cout << " WARNING! Fadc::FillOuter " << time << " out of TriggerTimeRange "
|
|---|
| 261 | << TOTAL_TRIGGER_TIME << endl ;
|
|---|
| 262 | }
|
|---|
| 263 |
|
|---|
| 264 | }
|
|---|
| 265 |
|
|---|
| 266 | void MFadc::Set( Int_t iPix, Float_t resp[(Int_t) SLICES_MFADC]) {
|
|---|
| 267 |
|
|---|
| 268 | //
|
|---|
| 269 | // Sets the information about fadc reponse from a given array
|
|---|
| 270 | //
|
|---|
| 271 | // parameter is the number of the pixel and the values to be set
|
|---|
| 272 | //
|
|---|
| 273 | //
|
|---|
| 274 |
|
|---|
| 275 | Int_t i ;
|
|---|
| 276 |
|
|---|
| 277 | //
|
|---|
| 278 | // first we have to check if the pixel iPix is used or not until now
|
|---|
| 279 | // if this is the first use, reset all signal for that pixels
|
|---|
| 280 | //
|
|---|
| 281 | if ( iPix > numpix ) {
|
|---|
| 282 | cout << " WARNING: MFadc::Fill() : iPix greater than CAMERA_PIXELS"
|
|---|
| 283 | << endl ;
|
|---|
| 284 | exit(987) ;
|
|---|
| 285 | }
|
|---|
| 286 |
|
|---|
| 287 | if ( used[iPix] == FALSE ) {
|
|---|
| 288 | used [iPix] = TRUE ;
|
|---|
| 289 |
|
|---|
| 290 | for (i=0; i < (Int_t)SLICES_MFADC; i++ ) {
|
|---|
| 291 | sig[iPix][i] = 0. ;
|
|---|
| 292 | }
|
|---|
| 293 | }
|
|---|
| 294 | for ( i = 0 ; i<(Int_t)SLICES_MFADC; i++ ) {
|
|---|
| 295 | sig[iPix][i] = resp[i] ;
|
|---|
| 296 | }
|
|---|
| 297 |
|
|---|
| 298 | }
|
|---|
| 299 |
|
|---|
| 300 | void MFadc::AddSignal( Int_t iPix, Float_t resp[(Int_t) SLICES_MFADC]) {
|
|---|
| 301 |
|
|---|
| 302 | //
|
|---|
| 303 | // Adds signals to the fadc reponse from a given array
|
|---|
| 304 | //
|
|---|
| 305 | // parameter is the number of the pixel and the values to be added
|
|---|
| 306 | //
|
|---|
| 307 | //
|
|---|
| 308 |
|
|---|
| 309 | Int_t i ;
|
|---|
| 310 |
|
|---|
| 311 | //
|
|---|
| 312 | // first we have to check if the pixel iPix is used or not until now
|
|---|
| 313 | // if this is the first use, reset all signal for that pixels
|
|---|
| 314 | //
|
|---|
| 315 | if ( iPix > numpix ) {
|
|---|
| 316 | cout << " WARNING: MFadc::Fill() : iPix greater than CAMERA_PIXELS"
|
|---|
| 317 | << endl ;
|
|---|
| 318 | exit(987) ;
|
|---|
| 319 | }
|
|---|
| 320 |
|
|---|
| 321 | if ( used[iPix] == FALSE ) {
|
|---|
| 322 | used [iPix] = TRUE ;
|
|---|
| 323 |
|
|---|
| 324 | for (i=0; i < (Int_t)SLICES_MFADC; i++ ) {
|
|---|
| 325 | sig[iPix][i] = 0. ;
|
|---|
| 326 | }
|
|---|
| 327 | }
|
|---|
| 328 | for ( i = 0 ; i<(Int_t)SLICES_MFADC; i++ ) {
|
|---|
| 329 | sig[iPix][i] += resp[i] ;
|
|---|
| 330 | }
|
|---|
| 331 |
|
|---|
| 332 | }
|
|---|
| 333 |
|
|---|
| 334 | void MFadc::SetPedestals( Int_t ped) {
|
|---|
| 335 | // It sets pedestal for each pixel flat randomly dstributed between 0 and ped
|
|---|
| 336 | // It uses the instance of TRandom GenElec.
|
|---|
| 337 |
|
|---|
| 338 | Int_t i;
|
|---|
| 339 |
|
|---|
| 340 | for(i=0;i<numpix;i++){
|
|---|
| 341 | pedestal[i]= (Float_t)(ped* GenElec->Rndm());
|
|---|
| 342 | }
|
|---|
| 343 | }
|
|---|
| 344 |
|
|---|
| 345 | void MFadc::SetPedestals( Float_t *ped) {
|
|---|
| 346 | // It sets pedestal for each pixel from ped array
|
|---|
| 347 |
|
|---|
| 348 | Int_t i;
|
|---|
| 349 |
|
|---|
| 350 | for(i=0;i<numpix;i++){
|
|---|
| 351 | pedestal[i]= ped[i];
|
|---|
| 352 | }
|
|---|
| 353 | }
|
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 | void MFadc::Baseline(){
|
|---|
| 357 | //
|
|---|
| 358 | // It simulates the AC behaviour
|
|---|
| 359 |
|
|---|
| 360 | int i,j;
|
|---|
| 361 | Float_t baseline;
|
|---|
| 362 |
|
|---|
| 363 | for(j=0;j<numpix;j++){
|
|---|
| 364 | baseline=0.0;
|
|---|
| 365 | for(i=0;i<(Int_t) SLICES_MFADC;i++){
|
|---|
| 366 | baseline=+sig[j][i];
|
|---|
| 367 | }
|
|---|
| 368 | baseline=baseline/SLICES_MFADC;
|
|---|
| 369 | for(i=0;i<(Int_t) SLICES_MFADC;i++){
|
|---|
| 370 | sig[j][i]=-baseline;
|
|---|
| 371 | }
|
|---|
| 372 | }
|
|---|
| 373 | }
|
|---|
| 374 |
|
|---|
| 375 | void MFadc::Pedestals(){
|
|---|
| 376 | //
|
|---|
| 377 | // It shifts the FADC contents their pedestal values
|
|---|
| 378 | // It shifts the values in the analog signal,
|
|---|
| 379 | // therefore it has to be done before getting FADC output
|
|---|
| 380 | //
|
|---|
| 381 |
|
|---|
| 382 | Int_t i, j;
|
|---|
| 383 |
|
|---|
| 384 | for(i=0;i<numpix;i++)
|
|---|
| 385 | for(j=0;j<(Int_t)SLICES_MFADC;j++){
|
|---|
| 386 | if(used[i])
|
|---|
| 387 | sig[i][j]+=pedestal[i];
|
|---|
| 388 | else
|
|---|
| 389 | sig[i][j]=pedestal[i];
|
|---|
| 390 | }
|
|---|
| 391 |
|
|---|
| 392 | }
|
|---|
| 393 |
|
|---|
| 394 | void MFadc::Offset(Float_t offset, Int_t pixel){
|
|---|
| 395 | //
|
|---|
| 396 | // It puts an offset in the FADC signal
|
|---|
| 397 | //
|
|---|
| 398 |
|
|---|
| 399 | int i,j;
|
|---|
| 400 | float fdum;
|
|---|
| 401 | TRandom *GenOff = new TRandom () ;
|
|---|
| 402 |
|
|---|
| 403 | if (offset<0) {
|
|---|
| 404 | // It cannot be, so the program assumes that
|
|---|
| 405 | // it should generate random values for the offset.
|
|---|
| 406 |
|
|---|
| 407 | if (pixel<0) {
|
|---|
| 408 | // It does not exist, so all pixels will have the same offset
|
|---|
| 409 |
|
|---|
| 410 | for(i=0;i<numpix;i++){
|
|---|
| 411 | if (used[i]){
|
|---|
| 412 | fdum=(10*GenOff->Rndm());
|
|---|
| 413 | for(j=0;j<(Int_t) SLICES_MFADC;j++)
|
|---|
| 414 | sig[i][j]=+fdum;
|
|---|
| 415 | }
|
|---|
| 416 | }
|
|---|
| 417 | } else {
|
|---|
| 418 | // The program will put the specifies offset to the pixel "pixel".
|
|---|
| 419 |
|
|---|
| 420 | if (used[pixel]){
|
|---|
| 421 | fdum=(10*GenOff->Rndm());
|
|---|
| 422 | for(j=0;j<(Int_t) SLICES_MFADC;j++)
|
|---|
| 423 | sig[pixel][j]=+fdum;
|
|---|
| 424 | }
|
|---|
| 425 |
|
|---|
| 426 | }
|
|---|
| 427 | }else {
|
|---|
| 428 | // The "offset" will be the offset for the FADC
|
|---|
| 429 |
|
|---|
| 430 | if (pixel<0) {
|
|---|
| 431 | // It does not exist, so all pixels will have the same offset
|
|---|
| 432 |
|
|---|
| 433 | for(i=0;i<numpix;i++){
|
|---|
| 434 | if (used[i]){
|
|---|
| 435 | for(j=0;j<(Int_t) SLICES_MFADC;j++)
|
|---|
| 436 | sig[i][j]=+offset;
|
|---|
| 437 | }
|
|---|
| 438 | }
|
|---|
| 439 | } else {
|
|---|
| 440 | // The program will put the specifies offset to the pixel "pixel".
|
|---|
| 441 |
|
|---|
| 442 | if (used[pixel]){
|
|---|
| 443 | for(j=0;j<(Int_t) SLICES_MFADC;j++)
|
|---|
| 444 | sig[pixel][j]=+offset;
|
|---|
| 445 | }
|
|---|
| 446 | }
|
|---|
| 447 | }
|
|---|
| 448 | delete GenOff;
|
|---|
| 449 | }
|
|---|
| 450 |
|
|---|
| 451 | void MFadc::SetElecNoise(Float_t value){
|
|---|
| 452 |
|
|---|
| 453 | UInt_t i;
|
|---|
| 454 |
|
|---|
| 455 | cout<<"MFadc::SetElecNoise ... generating database for electronic noise."
|
|---|
| 456 | <<endl;
|
|---|
| 457 |
|
|---|
| 458 | for (i=0;i<(UInt_t (SLICES_MFADC))*1001;i++){
|
|---|
| 459 | noise[i]=GenElec->Gaus(0., value );
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 | cout<<"MFadc::SetElecNoise ... done"<<endl;
|
|---|
| 463 |
|
|---|
| 464 | }
|
|---|
| 465 |
|
|---|
| 466 | void MFadc::ElecNoise(Float_t value) {
|
|---|
| 467 | // ============================================================
|
|---|
| 468 | //
|
|---|
| 469 | // adds the noise due to optronic and electronic
|
|---|
| 470 | // to the signal
|
|---|
| 471 | //
|
|---|
| 472 | UInt_t startslice;
|
|---|
| 473 |
|
|---|
| 474 | for ( Int_t i = 0 ; i < numpix; i++) {
|
|---|
| 475 | //
|
|---|
| 476 | // but at the beginning we must check if this pixel is
|
|---|
| 477 | // hitted the first time
|
|---|
| 478 | //
|
|---|
| 479 |
|
|---|
| 480 | startslice=GenElec->Integer(((Int_t)SLICES_MFADC)*1000);
|
|---|
| 481 |
|
|---|
| 482 | if ( used[i] == FALSE ) {
|
|---|
| 483 | used [i] = TRUE ;
|
|---|
| 484 |
|
|---|
| 485 | memcpy( (Float_t*)&sig[i][0],
|
|---|
| 486 | (Float_t*)&noise[startslice],
|
|---|
| 487 | ((Int_t) SLICES_MFADC)*sizeof(Float_t));
|
|---|
| 488 |
|
|---|
| 489 | for ( Int_t is=0 ; is< (Int_t)SLICES_MFADC ; is++ ) {
|
|---|
| 490 |
|
|---|
| 491 | }
|
|---|
| 492 | }
|
|---|
| 493 | //
|
|---|
| 494 | // Then the noise is introduced for each time slice
|
|---|
| 495 | //
|
|---|
| 496 | else
|
|---|
| 497 | for ( Int_t is=0 ; is< (Int_t)SLICES_MFADC ; is++ ) {
|
|---|
| 498 |
|
|---|
| 499 | sig[i][is] += noise[startslice+is] ;
|
|---|
| 500 |
|
|---|
| 501 | }
|
|---|
| 502 | }
|
|---|
| 503 | }
|
|---|
| 504 |
|
|---|
| 505 | void MFadc::SetDigitalNoise(Float_t value){
|
|---|
| 506 |
|
|---|
| 507 | UInt_t i;
|
|---|
| 508 | Float_t xrdm;
|
|---|
| 509 |
|
|---|
| 510 | cout<<"MFadc::SetDigitalNoise ... generating database for electronic noise."
|
|---|
| 511 | <<endl;
|
|---|
| 512 |
|
|---|
| 513 | for (i=0;i<UInt_t(SLICES_MFADC*1001);i++){
|
|---|
| 514 | xrdm=GenElec->Gaus(0., value);
|
|---|
| 515 | digital_noise[i]=(xrdm>0?Int_t(xrdm+0.5):Int_t(xrdm-0.5));
|
|---|
| 516 | }
|
|---|
| 517 |
|
|---|
| 518 | cout<<"MFadc::SetDigitalNoise ... done"<<endl;
|
|---|
| 519 |
|
|---|
| 520 | }
|
|---|
| 521 |
|
|---|
| 522 | void MFadc::DigitalNoise() {
|
|---|
| 523 | // ============================================================
|
|---|
| 524 | //
|
|---|
| 525 | // adds the noise due to optronic and electronic
|
|---|
| 526 | // to the signal
|
|---|
| 527 | //
|
|---|
| 528 | UInt_t startslice;
|
|---|
| 529 |
|
|---|
| 530 | for ( Int_t i = 0 ; i < numpix; i++) {
|
|---|
| 531 |
|
|---|
| 532 | if ( used[i] == TRUE ) {
|
|---|
| 533 | startslice=GenElec->Integer((Int_t) SLICES_MFADC*999);
|
|---|
| 534 | //
|
|---|
| 535 | // Then the noise is introduced for each time slice
|
|---|
| 536 | //
|
|---|
| 537 | for ( Int_t is=0 ; is< FADC_SLICES; is++ ) {
|
|---|
| 538 |
|
|---|
| 539 | if(digital_noise[startslice+is]+Int_t(output[i][is])<0)
|
|---|
| 540 | output[i][is] = 0;
|
|---|
| 541 | else
|
|---|
| 542 | output[i][is] =
|
|---|
| 543 | (digital_noise[startslice+is]+Int_t(output[i][is])>255 ?
|
|---|
| 544 | 255 :
|
|---|
| 545 | UChar_t(digital_noise[startslice+is]+Int_t(output[i][is])));
|
|---|
| 546 | if(digital_noise[startslice+FADC_SLICES+is]+Int_t(output_lowgain[i][is])<0)
|
|---|
| 547 | output_lowgain[i][is] = 0;
|
|---|
| 548 | else
|
|---|
| 549 | output_lowgain[i][is] =
|
|---|
| 550 | (digital_noise[startslice+FADC_SLICES+is]
|
|---|
| 551 | +Int_t(output_lowgain[i][is])>255?
|
|---|
| 552 | 255:
|
|---|
| 553 | UChar_t(digital_noise[startslice+FADC_SLICES+is]
|
|---|
| 554 | +Int_t(output_lowgain[i][is])));
|
|---|
| 555 | }
|
|---|
| 556 | }
|
|---|
| 557 | }
|
|---|
| 558 | }
|
|---|
| 559 |
|
|---|
| 560 |
|
|---|
| 561 | void MFadc::Scan() {
|
|---|
| 562 |
|
|---|
| 563 |
|
|---|
| 564 | for ( Int_t ip=0; ip<numpix; ip++ ) {
|
|---|
| 565 |
|
|---|
| 566 | if ( used[ip] == kTRUE ) {
|
|---|
| 567 |
|
|---|
| 568 | printf ("Pid %3d", ip ) ;
|
|---|
| 569 |
|
|---|
| 570 | for ( Int_t is=0 ; is < (Int_t)SLICES_MFADC; is++ ) {
|
|---|
| 571 |
|
|---|
| 572 | if ( sig[ip][is] > 0. ) {
|
|---|
| 573 | printf (" %4.1f/", sig[ip][is] ) ;
|
|---|
| 574 | }
|
|---|
| 575 | else {
|
|---|
| 576 | printf ("----/" ) ;
|
|---|
| 577 | }
|
|---|
| 578 | }
|
|---|
| 579 |
|
|---|
| 580 | printf ("\n");
|
|---|
| 581 |
|
|---|
| 582 | }
|
|---|
| 583 | }
|
|---|
| 584 |
|
|---|
| 585 | }
|
|---|
| 586 |
|
|---|
| 587 | void MFadc::Scan(Float_t time) {
|
|---|
| 588 |
|
|---|
| 589 | //
|
|---|
| 590 | // first of all we subtract from the time a offset (8 ns)
|
|---|
| 591 | //
|
|---|
| 592 |
|
|---|
| 593 | Float_t t ;
|
|---|
| 594 |
|
|---|
| 595 | (0 > time - TIME_BEFORE_TRIGGER)? t=0: t=(time-TIME_BEFORE_TRIGGER) ; // to show also the start of the pulse before the trigger time
|
|---|
| 596 |
|
|---|
| 597 | if ( t < 0. ) {
|
|---|
| 598 | cout << " WARNING!! FROM MFADC::SCAN(t) " << endl ;
|
|---|
| 599 | exit (776) ;
|
|---|
| 600 | }
|
|---|
| 601 |
|
|---|
| 602 | //
|
|---|
| 603 | // calculate the first slice to write out
|
|---|
| 604 | //
|
|---|
| 605 |
|
|---|
| 606 | Int_t iFirstSlice ;
|
|---|
| 607 |
|
|---|
| 608 | iFirstSlice = (Int_t) ( t / WIDTH_FADC_TIMESLICE ) ;
|
|---|
| 609 |
|
|---|
| 610 | for ( Int_t ip=0; ip<numpix; ip++ ) {
|
|---|
| 611 |
|
|---|
| 612 | if ( used[ip] == kTRUE ) {
|
|---|
| 613 |
|
|---|
| 614 | printf ("Pid %3d", ip ) ;
|
|---|
| 615 |
|
|---|
| 616 | for ( Int_t is=iFirstSlice ; is < (iFirstSlice+15); is++ ) {
|
|---|
| 617 | printf (" %5.2f /", sig[ip][is] ) ;
|
|---|
| 618 | }
|
|---|
| 619 |
|
|---|
| 620 | printf ("\n");
|
|---|
| 621 |
|
|---|
| 622 | }
|
|---|
| 623 | }
|
|---|
| 624 | }
|
|---|
| 625 |
|
|---|
| 626 | void MFadc::GetResponse( Float_t *resp ) {
|
|---|
| 627 | // ============================================================
|
|---|
| 628 | //
|
|---|
| 629 | // puts the standard response function into the array resp
|
|---|
| 630 |
|
|---|
| 631 | for ( Int_t i=0; i< RESPONSE_SLICES; i++ ) {
|
|---|
| 632 |
|
|---|
| 633 | resp[i] = sing_resp[i] ;
|
|---|
| 634 | }
|
|---|
| 635 | }
|
|---|
| 636 |
|
|---|
| 637 | void MFadc::GetPedestals( Float_t *offset) {
|
|---|
| 638 | // ============================================================
|
|---|
| 639 | //
|
|---|
| 640 | // puts the pedestal values into the array offset
|
|---|
| 641 |
|
|---|
| 642 | for ( Int_t i=0; i< numpix; i++ ) {
|
|---|
| 643 |
|
|---|
| 644 | offset[i] = pedestal[i] ;
|
|---|
| 645 | }
|
|---|
| 646 | }
|
|---|
| 647 |
|
|---|
| 648 | Float_t MFadc::GetPedestalNoise( Int_t pix, Int_t ishigh) {
|
|---|
| 649 | // ============================================================
|
|---|
| 650 | //
|
|---|
| 651 | // computes the pedestal sigma for channel pix
|
|---|
| 652 |
|
|---|
| 653 | Float_t sigma=0;
|
|---|
| 654 | UChar_t value=0;
|
|---|
| 655 |
|
|---|
| 656 | Float_t factor;
|
|---|
| 657 | UInt_t startslice;
|
|---|
| 658 |
|
|---|
| 659 | factor=(ishigh?1.0:high2low_gain);
|
|---|
| 660 |
|
|---|
| 661 | startslice=GenElec->Integer((Int_t) SLICES_MFADC*999);
|
|---|
| 662 |
|
|---|
| 663 | for ( Int_t is=0; is < (Int_t)SLICES_MFADC ; is++ ) {
|
|---|
| 664 | if (pedestal[pix]+(sig[pix][is]-pedestal[pix])/factor>0.0){
|
|---|
| 665 | value=(pedestal[pix]+(sig[pix][is]-pedestal[pix])/factor > 255.
|
|---|
| 666 | ? 255
|
|---|
| 667 | :UChar_t(pedestal[pix]+(sig[pix][is]-pedestal[pix])/factor+0.5));
|
|---|
| 668 | if(Int_t(value)+digital_noise[startslice+is]<0.0)
|
|---|
| 669 | value=0;
|
|---|
| 670 | else
|
|---|
| 671 | value=(Int_t(value)+digital_noise[startslice+is]>255
|
|---|
| 672 | ?255
|
|---|
| 673 | :UChar_t(Int_t(value)+digital_noise[startslice+is]));
|
|---|
| 674 | }
|
|---|
| 675 | else {
|
|---|
| 676 | value= 0;
|
|---|
| 677 | if(Int_t(value)+digital_noise[startslice+is]<0.0)
|
|---|
| 678 | value=0;
|
|---|
| 679 | else
|
|---|
| 680 | value=(Int_t(value)+digital_noise[startslice+is]>255
|
|---|
| 681 | ?255
|
|---|
| 682 | :UChar_t(Int_t(value)+digital_noise[startslice+is]));
|
|---|
| 683 | }
|
|---|
| 684 | sigma+=((Float_t)value-pedestal[pix])*((Float_t)value-pedestal[pix]);
|
|---|
| 685 | }
|
|---|
| 686 |
|
|---|
| 687 |
|
|---|
| 688 | sigma=sqrt(sigma/(SLICES_MFADC-1));
|
|---|
| 689 |
|
|---|
| 690 | return sigma;
|
|---|
| 691 | }
|
|---|
| 692 |
|
|---|
| 693 | void MFadc::TriggeredFadc(Float_t time) {
|
|---|
| 694 |
|
|---|
| 695 | //
|
|---|
| 696 | // first of all we subtract from the time a offset (8 ns)
|
|---|
| 697 | //
|
|---|
| 698 |
|
|---|
| 699 | Float_t t ;
|
|---|
| 700 |
|
|---|
| 701 | (0>time-TIME_BEFORE_TRIGGER)? t=0: t=(time-TIME_BEFORE_TRIGGER) ; // to show also the start of the pulse before the trigger time
|
|---|
| 702 |
|
|---|
| 703 | if ( t < 0. ) {
|
|---|
| 704 | cout << " WARNING!! FROM MFADC::SCAN(t) " << endl ;
|
|---|
| 705 | exit (776) ;
|
|---|
| 706 | }
|
|---|
| 707 |
|
|---|
| 708 | //
|
|---|
| 709 | // calculate the first slice to write out
|
|---|
| 710 | //
|
|---|
| 711 |
|
|---|
| 712 | Int_t iFirstSlice ;
|
|---|
| 713 | Int_t i;
|
|---|
| 714 |
|
|---|
| 715 | iFirstSlice = (Int_t) ( t / WIDTH_FADC_TIMESLICE ) ;
|
|---|
| 716 |
|
|---|
| 717 | for ( Int_t ip=0; ip<numpix; ip++ ) {
|
|---|
| 718 |
|
|---|
| 719 | if ( used[ip] == kTRUE ) {
|
|---|
| 720 | i=0;
|
|---|
| 721 | for ( Int_t is=iFirstSlice ; is < (iFirstSlice+FADC_SLICES) ; is++ ) {
|
|---|
| 722 | if (is< (Int_t)SLICES_MFADC && sig[ip][is]>0.0)
|
|---|
| 723 | {
|
|---|
| 724 |
|
|---|
| 725 | output[ip][i]=(sig[ip][is] > 255. ? 255 :(UChar_t) (sig[ip][is]+0.5));
|
|---|
| 726 | output_lowgain[ip][i]=
|
|---|
| 727 | (Int_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain+0.5) > 255. ? 255 :
|
|---|
| 728 | (UChar_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain+0.5);
|
|---|
| 729 | i++;
|
|---|
| 730 |
|
|---|
| 731 | }
|
|---|
| 732 | else if(sig[ip][is]>=0.0)
|
|---|
| 733 | {
|
|---|
| 734 | output[ip][i]= (UChar_t)(pedestal[ip]+0.5);
|
|---|
| 735 | output_lowgain[ip][i]= (UChar_t)(pedestal[ip]+0.5);
|
|---|
| 736 | i++;
|
|---|
| 737 | }
|
|---|
| 738 | else
|
|---|
| 739 | {
|
|---|
| 740 | output[ip][i]= 0;
|
|---|
| 741 | if((pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain)<0)
|
|---|
| 742 | output_lowgain[ip][i]= 0;
|
|---|
| 743 | else
|
|---|
| 744 | output_lowgain[ip][i]=(UChar_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain+0.5);
|
|---|
| 745 | i++;
|
|---|
| 746 | }
|
|---|
| 747 | }
|
|---|
| 748 | }
|
|---|
| 749 | }
|
|---|
| 750 | }
|
|---|
| 751 |
|
|---|
| 752 | void MFadc::ShowSignal (MMcEvt *McEvt, Float_t trigTime) {
|
|---|
| 753 | // ============================================================
|
|---|
| 754 | //
|
|---|
| 755 | // This method is used to book the histogram to show the signal in
|
|---|
| 756 | // a special gui frame (class MGTriggerSignal). After the look onto the
|
|---|
| 757 | // signals for a better understanding of the things we will expect
|
|---|
| 758 | // the gui frame and all histogramms will be destroyed.
|
|---|
| 759 | //
|
|---|
| 760 |
|
|---|
| 761 | //
|
|---|
| 762 | // first of all create a list of the histograms to show
|
|---|
| 763 | //
|
|---|
| 764 | // take only that one with a entry
|
|---|
| 765 |
|
|---|
| 766 | TH1F *hist ;
|
|---|
| 767 | Char_t dumm[10];
|
|---|
| 768 | Char_t name[256];
|
|---|
| 769 |
|
|---|
| 770 | TObjArray *AList ;
|
|---|
| 771 | AList = new TObjArray(10) ;
|
|---|
| 772 |
|
|---|
| 773 | // the list of analog signal histograms
|
|---|
| 774 | // at the beginning we initalise 10 elements
|
|---|
| 775 | // but this array expand automaticly if neccessay
|
|---|
| 776 |
|
|---|
| 777 | Int_t ic = 0 ;
|
|---|
| 778 | for ( Int_t i=0 ; i < numpix; i++ ) {
|
|---|
| 779 | if ( used [i] == TRUE ) {
|
|---|
| 780 |
|
|---|
| 781 | sprintf (dumm, "FADC_%d", i ) ;
|
|---|
| 782 | sprintf (name, "fadc signal %d", i ) ;
|
|---|
| 783 |
|
|---|
| 784 | hist = new TH1F(dumm, name, SLICES_MFADC, 0., TOTAL_TRIGGER_TIME);
|
|---|
| 785 | //
|
|---|
| 786 | // fill the histogram
|
|---|
| 787 | //
|
|---|
| 788 |
|
|---|
| 789 | for (Int_t ibin=1; ibin <=(Int_t)SLICES_MFADC; ibin++) {
|
|---|
| 790 | hist->SetBinContent (ibin, sig[i][ibin-1]) ;
|
|---|
| 791 | }
|
|---|
| 792 |
|
|---|
| 793 | // hist->SetMaximum( 5.);
|
|---|
| 794 | // hist->SetMinimum(-10.);
|
|---|
| 795 | hist->SetStats(kFALSE);
|
|---|
| 796 |
|
|---|
| 797 | // hist->SetAxisRange(0., 80. ) ;
|
|---|
| 798 |
|
|---|
| 799 | AList->Add(hist) ;
|
|---|
| 800 |
|
|---|
| 801 | ic++ ;
|
|---|
| 802 | }
|
|---|
| 803 | }
|
|---|
| 804 |
|
|---|
| 805 | //
|
|---|
| 806 | // create the Gui Tool
|
|---|
| 807 | //
|
|---|
| 808 | //
|
|---|
| 809 |
|
|---|
| 810 | new MGFadcSignal(McEvt,
|
|---|
| 811 | AList,
|
|---|
| 812 | trigTime,
|
|---|
| 813 | gClient->GetRoot(),
|
|---|
| 814 | gClient->GetRoot(),
|
|---|
| 815 | 400, 400 ) ;
|
|---|
| 816 |
|
|---|
| 817 | //
|
|---|
| 818 | // delete the List of histogramms
|
|---|
| 819 | //
|
|---|
| 820 | AList->Delete() ;
|
|---|
| 821 |
|
|---|
| 822 | delete AList ;
|
|---|
| 823 | }
|
|---|
| 824 |
|
|---|
| 825 | UChar_t MFadc::GetFadcSignal(Int_t pixel, Int_t slice){
|
|---|
| 826 |
|
|---|
| 827 | // It returns the analog signal for a given pixel and a given FADC
|
|---|
| 828 | // time slice which would be read.
|
|---|
| 829 |
|
|---|
| 830 | return (output[pixel][slice]);
|
|---|
| 831 | }
|
|---|
| 832 |
|
|---|
| 833 |
|
|---|
| 834 | UChar_t MFadc::GetFadcLowGainSignal(Int_t pixel, Int_t slice){
|
|---|
| 835 |
|
|---|
| 836 | // It returns the analog signal for a given pixel and a given FADC
|
|---|
| 837 | // time slice which would be read.
|
|---|
| 838 |
|
|---|
| 839 | return (output_lowgain[pixel][slice]);
|
|---|
| 840 | }
|
|---|
| 841 |
|
|---|
| 842 |
|
|---|
| 843 |
|
|---|