]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSCalibrationSDD.cxx
New SPD simulation (Massimo):
[u/mrichter/AliRoot.git] / ITS / AliITSCalibrationSDD.cxx
CommitLineData
fcf95fc7 1/**************************************************************************
5bfe44ce 2
fcf95fc7 3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5bfe44ce 4
fcf95fc7 5 * *
5bfe44ce 6
fcf95fc7 7 * Author: The ALICE Off-line Project. *
5bfe44ce 8
fcf95fc7 9 * Contributors are mentioned in the code where appropriate. *
5bfe44ce 10
fcf95fc7 11 * *
5bfe44ce 12
fcf95fc7 13 * Permission to use, copy, modify and distribute this software and its *
5bfe44ce 14
fcf95fc7 15 * documentation strictly for non-commercial purposes is hereby granted *
5bfe44ce 16
fcf95fc7 17 * without fee, provided that the above copyright notice appears in all *
5bfe44ce 18
fcf95fc7 19 * copies and that both the copyright notice and this permission notice *
5bfe44ce 20
fcf95fc7 21 * appear in the supporting documentation. The authors make no claims *
5bfe44ce 22
fcf95fc7 23 * about the suitability of this software for any purpose. It is *
5bfe44ce 24
fcf95fc7 25 * provided "as is" without express or implied warranty. *
5bfe44ce 26
fcf95fc7 27 **************************************************************************/
28
29
5bfe44ce 30
31
32
fcf95fc7 33#include <Riostream.h>
5bfe44ce 34
fcf95fc7 35#include <TRandom.h>
5bfe44ce 36
fcf95fc7 37#include "AliITSCalibrationSDD.h"
5bfe44ce 38
f45f6658 39#include "AliLog.h"
fcf95fc7 40
5bfe44ce 41
42
fcf95fc7 43//////////////////////////////////////////////////////
5bfe44ce 44
fcf95fc7 45// Calibration class for set:ITS //
5bfe44ce 46
fcf95fc7 47// Specific subdetector implementation //
5bfe44ce 48
fcf95fc7 49// for silicon drift detectors //
5bfe44ce 50
fcf95fc7 51// //
5bfe44ce 52
fcf95fc7 53// //
5bfe44ce 54
fcf95fc7 55//////////////////////////////////////////////////////
56
5bfe44ce 57
58
fcf95fc7 59const Double_t AliITSCalibrationSDD::fgkTemperatureDefault = 296.;
5bfe44ce 60
fcf95fc7 61const Double_t AliITSCalibrationSDD::fgkNoiseDefault = 10.;
5bfe44ce 62
f45f6658 63const Double_t AliITSCalibrationSDD::fgkGainDefault = 1.;
5bfe44ce 64
fcf95fc7 65const Double_t AliITSCalibrationSDD::fgkBaselineDefault = 20.;
5bfe44ce 66
fcf95fc7 67const Double_t AliITSCalibrationSDD::fgkMinValDefault = 4;
5bfe44ce 68
fcf95fc7 69//______________________________________________________________________
5bfe44ce 70
fcf95fc7 71ClassImp(AliITSCalibrationSDD)
72
5bfe44ce 73
74
f45f6658 75AliITSCalibrationSDD::AliITSCalibrationSDD(){
5bfe44ce 76
fcf95fc7 77 // default constructor
78
5bfe44ce 79
80
fcf95fc7 81 SetDeadChannels();
5bfe44ce 82
f45f6658 83 fBadChannels.Set(fDeadChannels);
5bfe44ce 84
f45f6658 85 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
5bfe44ce 86
f45f6658 87 fBaseline[ian]=fgkBaselineDefault;
5bfe44ce 88
f45f6658 89 fNoise[ian]=fgkNoiseDefault;
5bfe44ce 90
f45f6658 91 SetNoiseAfterElectronics(ian);
5bfe44ce 92
f45f6658 93 }
5bfe44ce 94
f45f6658 95 for(Int_t iw=0;iw<fgkWings;iw++){
5bfe44ce 96
f45f6658 97 for(Int_t icp=0;icp<fgkChips;icp++){
5bfe44ce 98
f45f6658 99 for(Int_t ich=0;ich<fgkChannels;ich++)
5bfe44ce 100
f45f6658 101 fGain[iw][icp][ich]=1.;
5bfe44ce 102
f45f6658 103 }
5bfe44ce 104
f45f6658 105 }
5bfe44ce 106
fcf95fc7 107 SetThresholds(fgkMinValDefault,0.);
5bfe44ce 108
fcf95fc7 109 SetTemperature(fgkTemperatureDefault);
5bfe44ce 110
fcf95fc7 111 SetDataType();
5bfe44ce 112
113 for(Int_t i=0;i<fgkChips*fgkChannels;i++){
114
115 for(Int_t j=0;j<fgkMapTimeNBin;j++){
116
117 fMapA[i][j]=0;
118
119 fMapT[i][j]=0;
120
121 }
122
123 }
124
fcf95fc7 125 }
5bfe44ce 126
fcf95fc7 127//______________________________________________________________________
5bfe44ce 128
fcf95fc7 129AliITSCalibrationSDD::AliITSCalibrationSDD(const char *dataType){
5bfe44ce 130
fcf95fc7 131 // constructor
132
5bfe44ce 133
134
fcf95fc7 135 SetDeadChannels();
5bfe44ce 136
f45f6658 137 fBadChannels.Set(fDeadChannels);
5bfe44ce 138
f45f6658 139 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
5bfe44ce 140
f45f6658 141 fBaseline[ian]=fgkBaselineDefault;
5bfe44ce 142
f45f6658 143 fNoise[ian]=fgkNoiseDefault;
5bfe44ce 144
f45f6658 145 SetNoiseAfterElectronics(ian);
5bfe44ce 146
f45f6658 147 }
5bfe44ce 148
f45f6658 149 for(Int_t iw=0;iw<fgkWings;iw++){
5bfe44ce 150
f45f6658 151 for(Int_t icp=0;icp<fgkChips;icp++){
5bfe44ce 152
f45f6658 153 for(Int_t ich=0;ich<fgkChannels;ich++)
5bfe44ce 154
f45f6658 155 fGain[iw][icp][ich]=1.;
5bfe44ce 156
f45f6658 157 }
5bfe44ce 158
f45f6658 159 }
fcf95fc7 160
5bfe44ce 161
162
fcf95fc7 163 SetThresholds(fgkMinValDefault,0.);
5bfe44ce 164
fcf95fc7 165 SetTemperature(fgkTemperatureDefault);
5bfe44ce 166
fcf95fc7 167 SetDataType(dataType);
5bfe44ce 168
169 for(Int_t i=0;i<fgkChips*fgkChannels;i++){
170
171 for(Int_t j=0;j<fgkMapTimeNBin;j++){
172
173 fMapA[i][j]=0;
174
175 fMapT[i][j]=0;
176
177 }
178
179 }
180
181
182
fcf95fc7 183 }
5bfe44ce 184
fcf95fc7 185//______________________________________________________________________
5bfe44ce 186
fcf95fc7 187AliITSCalibrationSDD::AliITSCalibrationSDD(const AliITSCalibrationSDD &ob) : AliITSCalibration(ob) {
5bfe44ce 188
fcf95fc7 189 // Copy constructor
5bfe44ce 190
fcf95fc7 191 // Copies are not allowed. The method is protected to avoid misuse.
5bfe44ce 192
fcf95fc7 193 Error("AliITSCalibrationSDD","Copy constructor not allowed\n");
5bfe44ce 194
fcf95fc7 195}
196
5bfe44ce 197
198
fcf95fc7 199//______________________________________________________________________
5bfe44ce 200
fcf95fc7 201AliITSCalibrationSDD& AliITSCalibrationSDD::operator=(const AliITSCalibrationSDD& /* ob */){
5bfe44ce 202
fcf95fc7 203 // Assignment operator
5bfe44ce 204
fcf95fc7 205 // Assignment is not allowed. The method is protected to avoid misuse.
5bfe44ce 206
fcf95fc7 207 Error("= operator","Assignment operator not allowed\n");
5bfe44ce 208
fcf95fc7 209 return *this;
5bfe44ce 210
fcf95fc7 211}
212
5bfe44ce 213
214
fcf95fc7 215//______________________________________________________________________
5bfe44ce 216
f45f6658 217void AliITSCalibrationSDD::GiveCompressParam(Int_t cp[8],Int_t ian) const {
5bfe44ce 218
fcf95fc7 219 // give compression param
220
5bfe44ce 221
222
f45f6658 223 cp[0]=(Int_t) fBaseline[ian];
5bfe44ce 224
f45f6658 225 cp[1]=(Int_t) fBaseline[ian];
5bfe44ce 226
f45f6658 227 cp[2]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
5bfe44ce 228
f45f6658 229 cp[3]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
5bfe44ce 230
f45f6658 231 cp[4]=0;
5bfe44ce 232
f45f6658 233 cp[5]=0;
5bfe44ce 234
f45f6658 235 cp[6]=0;
5bfe44ce 236
f45f6658 237 cp[7]=0;
5bfe44ce 238
fcf95fc7 239}
5bfe44ce 240
f45f6658 241//_____________________________________________________________________
5bfe44ce 242
f45f6658 243void AliITSCalibrationSDD::SetBadChannel(Int_t i,Int_t anode){
5bfe44ce 244
f45f6658 245 //Set bad anode (set gain=0 for these channels);
fcf95fc7 246
5bfe44ce 247
248
f45f6658 249 if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
5bfe44ce 250
f45f6658 251 Int_t wing=0;
5bfe44ce 252
f45f6658 253 Int_t chip,channel;
5bfe44ce 254
f45f6658 255 chip=anode/fgkChannels;
5bfe44ce 256
f45f6658 257 channel=anode-(chip*fgkChannels);
5bfe44ce 258
f45f6658 259 if(anode>=fgkChips*fgkChannels) wing=1;
5bfe44ce 260
f45f6658 261 if(wing==1)chip-=fgkChips;
5bfe44ce 262
f45f6658 263 fBadChannels[i]=anode;
5bfe44ce 264
f45f6658 265 fGain[wing][chip][channel]=0;
5bfe44ce 266
f45f6658 267}
5bfe44ce 268
f45f6658 269//_____________________________________________________________________
5bfe44ce 270
f45f6658 271Bool_t AliITSCalibrationSDD::IsBadChannel(Int_t anode){
5bfe44ce 272
f45f6658 273 //returns kTRUE if the anode i (0-512) has fGain=0
5bfe44ce 274
f45f6658 275 if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
5bfe44ce 276
f45f6658 277 Int_t wing=0;
5bfe44ce 278
f45f6658 279 Int_t chip,channel;
5bfe44ce 280
f45f6658 281 chip=anode/fgkChannels;
5bfe44ce 282
f45f6658 283 channel=anode-(chip*fgkChannels);
5bfe44ce 284
f45f6658 285 if(anode>=fgkChips*fgkChannels) wing=1;
5bfe44ce 286
f45f6658 287 if(wing==1)chip-=fgkChips;
5bfe44ce 288
f45f6658 289 if(fGain[wing][chip][channel]==0) return kTRUE;
5bfe44ce 290
f45f6658 291 else return kFALSE;
5bfe44ce 292
f45f6658 293}
5bfe44ce 294
f45f6658 295/*
5bfe44ce 296
fcf95fc7 297//______________________________________________________________________
5bfe44ce 298
fcf95fc7 299void AliITSCalibrationSDD::SetDeadChannels(Int_t nchip, Int_t nchan){
5bfe44ce 300
fcf95fc7 301 // Set fGain to zero to simulate a random distribution of
5bfe44ce 302
fcf95fc7 303 // dead modules, dead chips and single dead channels
304
5bfe44ce 305
306
fcf95fc7 307 for( Int_t m=0; m<fgkWings; m++ )
5bfe44ce 308
fcf95fc7 309 for( Int_t n=0; n<fgkChips; n++ )
5bfe44ce 310
fcf95fc7 311 for( Int_t p=0; p<fgkChannels; p++ )
5bfe44ce 312
fcf95fc7 313 fGain[m][n][p] = 1.;
5bfe44ce 314
fcf95fc7 315
5bfe44ce 316
fcf95fc7 317 //fDeadModules = nmod;
5bfe44ce 318
fcf95fc7 319 fDeadChips = nchip;
5bfe44ce 320
fcf95fc7 321 fDeadChannels = nchan;
5bfe44ce 322
f45f6658 323 fBadChannels.Set(fDeadChannels);
5bfe44ce 324
fcf95fc7 325 // nothing to do
5bfe44ce 326
fcf95fc7 327 //if( nmod == 0 && nchip == 0 && nchan == 0 ) return;
328
5bfe44ce 329
330
fcf95fc7 331 if( nchip == 0 && nchan == 0 ) return;
5bfe44ce 332
fcf95fc7 333 // if( nmod < 0 || nmod > fgkModules )
5bfe44ce 334
fcf95fc7 335 // {
5bfe44ce 336
fcf95fc7 337 // cout << "Wrong number of dead modules: " << nmod << endl;
5bfe44ce 338
fcf95fc7 339 // return;
5bfe44ce 340
fcf95fc7 341 // }
5bfe44ce 342
fcf95fc7 343
5bfe44ce 344
fcf95fc7 345 Int_t nmax = fgkWings*fgkChips;
5bfe44ce 346
fcf95fc7 347 if( nchip < 0 || nchip > nmax )
5bfe44ce 348
fcf95fc7 349 {
5bfe44ce 350
fcf95fc7 351 cout << "Wrong number of dead chips: " << nchip << endl;
5bfe44ce 352
fcf95fc7 353 return;
5bfe44ce 354
fcf95fc7 355 }
5bfe44ce 356
fcf95fc7 357 nmax = (fgkWings*fgkChips - nchip)*fgkChannels;
5bfe44ce 358
fcf95fc7 359 if( nchan < 0 || nchan > nmax )
5bfe44ce 360
fcf95fc7 361 {
5bfe44ce 362
fcf95fc7 363 cout << "Wrong number of dead channels: " << nchan << endl;
5bfe44ce 364
fcf95fc7 365 return;
5bfe44ce 366
fcf95fc7 367 }
5bfe44ce 368
fcf95fc7 369
5bfe44ce 370
fcf95fc7 371 TRandom *gran = new TRandom();
5bfe44ce 372
fcf95fc7 373 // cout << "chips" << endl;
5bfe44ce 374
fcf95fc7 375 Int_t * chip = new Int_t[nchip];
5bfe44ce 376
fcf95fc7 377 Int_t i = 0;
5bfe44ce 378
fcf95fc7 379 while( i < nchip )
5bfe44ce 380
fcf95fc7 381 {
5bfe44ce 382
fcf95fc7 383 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
5bfe44ce 384
fcf95fc7 385 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing");
5bfe44ce 386
fcf95fc7 387
5bfe44ce 388
fcf95fc7 389 Int_t chi = (Int_t) (fgkChips*gran->Uniform() + 1.);
5bfe44ce 390
fcf95fc7 391 if( chi <=0 || chi > fgkChips ) Error("SetDeadChannels","Wrong chip:%d\n",chi);
5bfe44ce 392
fcf95fc7 393 i++;
5bfe44ce 394
fcf95fc7 395 chip[i-1] = chi;
5bfe44ce 396
fcf95fc7 397 for( Int_t m=0; m<fgkChannels; m++ )
5bfe44ce 398
fcf95fc7 399 fGain[wing-1][chi-1][m] = 0.;
5bfe44ce 400
fcf95fc7 401 }
402
5bfe44ce 403
404
fcf95fc7 405 Int_t * channel = new Int_t[nchan];
5bfe44ce 406
fcf95fc7 407 Int_t * channelChip = new Int_t[nchan];
5bfe44ce 408
fcf95fc7 409 i = 0;
5bfe44ce 410
fcf95fc7 411 while( i < nchan )
5bfe44ce 412
fcf95fc7 413 {
5bfe44ce 414
fcf95fc7 415 Int_t k; //loop variable
5bfe44ce 416
fcf95fc7 417 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
5bfe44ce 418
fcf95fc7 419 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing:%d\n",wing);
5bfe44ce 420
fcf95fc7 421 Int_t chipp = (Int_t) (fgkChips*gran->Uniform() + 1.);
5bfe44ce 422
fcf95fc7 423 if( chipp <=0 || chipp > fgkChips ) Error("SetDeadChannels","Wrong chip:%d",chipp);
5bfe44ce 424
fcf95fc7 425 Int_t flagChip = 0;
5bfe44ce 426
fcf95fc7 427 for( k=0; k<nchip; k++)
5bfe44ce 428
fcf95fc7 429 if( chipp == chip[k] ) {
5bfe44ce 430
fcf95fc7 431 flagChip = 1; break; }
5bfe44ce 432
fcf95fc7 433 if( flagChip == 1 ) continue;
5bfe44ce 434
fcf95fc7 435 i++;
5bfe44ce 436
fcf95fc7 437 channel[i-1] = (Int_t) (fgkChannels*gran->Uniform() + 1.);
5bfe44ce 438
fcf95fc7 439 if( channel[i-1] <=0 || channel[i-1] > fgkChannels )
5bfe44ce 440
fcf95fc7 441 Error("SetDeadChannels","Wrong channel:%d\n",channel[i-1]);
5bfe44ce 442
fcf95fc7 443 channelChip[i-1] = chipp;
5bfe44ce 444
fcf95fc7 445 fGain[wing-1][chipp-1][channel[i-1]-1] = 0.;
5bfe44ce 446
fcf95fc7 447 }
5bfe44ce 448
fcf95fc7 449
5bfe44ce 450
fcf95fc7 451 delete [] chip;
5bfe44ce 452
fcf95fc7 453 delete [] channel;
5bfe44ce 454
fcf95fc7 455 delete [] channelChip;
5bfe44ce 456
fcf95fc7 457}
5bfe44ce 458
f45f6658 459*/
5bfe44ce 460
fcf95fc7 461//______________________________________________________________________
5bfe44ce 462
fcf95fc7 463void AliITSCalibrationSDD::PrintGains() const{
5bfe44ce 464
fcf95fc7 465 //
466
5bfe44ce 467
468
fcf95fc7 469 if( GetDeadChips() == 0 &&
5bfe44ce 470
fcf95fc7 471 GetDeadChannels() == 0 )
5bfe44ce 472
fcf95fc7 473 return;
474
5bfe44ce 475
476
fcf95fc7 477 // Print Electronics Gains
5bfe44ce 478
fcf95fc7 479 cout << "**************************************************" << endl;
5bfe44ce 480
fcf95fc7 481 cout << " Print Electronics Gains " << endl;
5bfe44ce 482
fcf95fc7 483 cout << "**************************************************" << endl;
484
5bfe44ce 485
486
fcf95fc7 487 // Print SDD electronic gains
5bfe44ce 488
fcf95fc7 489 for(Int_t t=0; t<fgkWings;t++)
5bfe44ce 490
fcf95fc7 491 for(Int_t u=0; u<fgkChips;u++)
5bfe44ce 492
fcf95fc7 493 for(Int_t v=0; v<fgkChannels;v++)
5bfe44ce 494
fcf95fc7 495 {
5bfe44ce 496
fcf95fc7 497 if( fGain[t][u][v] != 1.0 )
5bfe44ce 498
fcf95fc7 499 cout << "Gain for wing: " << t+1 << ", Chip " << u+1 <<
5bfe44ce 500
fcf95fc7 501 ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
5bfe44ce 502
fcf95fc7 503 }
5bfe44ce 504
fcf95fc7 505}
5bfe44ce 506
fcf95fc7 507//______________________________________________________________________
5bfe44ce 508
fcf95fc7 509void AliITSCalibrationSDD::Print(){
5bfe44ce 510
fcf95fc7 511 // Print SDD response Parameters
512
5bfe44ce 513
514
fcf95fc7 515 cout << "**************************************************" << endl;
5bfe44ce 516
fcf95fc7 517 cout << " Silicon Drift Detector Response Parameters " << endl;
5bfe44ce 518
fcf95fc7 519 cout << "**************************************************" << endl;
5bfe44ce 520
fcf95fc7 521 cout << "Hardware compression parameters: " << endl;
5bfe44ce 522
f45f6658 523 cout << "Noise before electronics (arbitrary units): " << fNoise[0] << endl;
5bfe44ce 524
f45f6658 525 cout << "Baseline (ADC units): " << fBaseline[0] << endl;
5bfe44ce 526
f45f6658 527 cout << "Noise after electronics (ADC units): " << fNoiseAfterEl[0] << endl;
5bfe44ce 528
fcf95fc7 529 cout << "Temperature: " << Temperature() << " K " << endl;
5bfe44ce 530
fcf95fc7 531 cout << "Min. Value: " << fMinVal << endl;
5bfe44ce 532
fcf95fc7 533 PrintGains();
534
fcf95fc7 535
536
5bfe44ce 537}
fcf95fc7 538