1 /**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
7 * Author: The ALICE Off-line Project. *
9 * Contributors are mentioned in the code where appropriate. *
13 * Permission to use, copy, modify and distribute this software and its *
15 * documentation strictly for non-commercial purposes is hereby granted *
17 * without fee, provided that the above copyright notice appears in all *
19 * copies and that both the copyright notice and this permission notice *
21 * appear in the supporting documentation. The authors make no claims *
23 * about the suitability of this software for any purpose. It is *
25 * provided "as is" without express or implied warranty. *
27 **************************************************************************/
33 #include <Riostream.h>
37 #include "AliITSCalibrationSDD.h"
43 //////////////////////////////////////////////////////
45 // Calibration class for set:ITS //
47 // Specific subdetector implementation //
49 // for silicon drift detectors //
55 //////////////////////////////////////////////////////
59 const Double_t AliITSCalibrationSDD::fgkTemperatureDefault = 296.;
61 const Double_t AliITSCalibrationSDD::fgkNoiseDefault = 10.;
63 const Double_t AliITSCalibrationSDD::fgkGainDefault = 1.;
65 const Double_t AliITSCalibrationSDD::fgkBaselineDefault = 20.;
67 const Double_t AliITSCalibrationSDD::fgkMinValDefault = 4;
69 //______________________________________________________________________
71 ClassImp(AliITSCalibrationSDD)
75 AliITSCalibrationSDD::AliITSCalibrationSDD(){
77 // default constructor
83 fBadChannels.Set(fDeadChannels);
85 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
87 fBaseline[ian]=fgkBaselineDefault;
89 fNoise[ian]=fgkNoiseDefault;
91 SetNoiseAfterElectronics(ian);
95 for(Int_t iw=0;iw<fgkWings;iw++){
97 for(Int_t icp=0;icp<fgkChips;icp++){
99 for(Int_t ich=0;ich<fgkChannels;ich++)
101 fGain[iw][icp][ich]=1.;
107 SetThresholds(fgkMinValDefault,0.);
109 SetTemperature(fgkTemperatureDefault);
113 for(Int_t i=0;i<fgkChips*fgkChannels;i++){
115 for(Int_t j=0;j<fgkMapTimeNBin;j++){
127 //______________________________________________________________________
129 AliITSCalibrationSDD::AliITSCalibrationSDD(const char *dataType){
137 fBadChannels.Set(fDeadChannels);
139 for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
141 fBaseline[ian]=fgkBaselineDefault;
143 fNoise[ian]=fgkNoiseDefault;
145 SetNoiseAfterElectronics(ian);
149 for(Int_t iw=0;iw<fgkWings;iw++){
151 for(Int_t icp=0;icp<fgkChips;icp++){
153 for(Int_t ich=0;ich<fgkChannels;ich++)
155 fGain[iw][icp][ich]=1.;
163 SetThresholds(fgkMinValDefault,0.);
165 SetTemperature(fgkTemperatureDefault);
167 SetDataType(dataType);
169 for(Int_t i=0;i<fgkChips*fgkChannels;i++){
171 for(Int_t j=0;j<fgkMapTimeNBin;j++){
185 //______________________________________________________________________
187 AliITSCalibrationSDD::AliITSCalibrationSDD(const AliITSCalibrationSDD &ob) : AliITSCalibration(ob) {
191 // Copies are not allowed. The method is protected to avoid misuse.
193 Error("AliITSCalibrationSDD","Copy constructor not allowed\n");
199 //______________________________________________________________________
201 AliITSCalibrationSDD& AliITSCalibrationSDD::operator=(const AliITSCalibrationSDD& /* ob */){
203 // Assignment operator
205 // Assignment is not allowed. The method is protected to avoid misuse.
207 Error("= operator","Assignment operator not allowed\n");
215 //______________________________________________________________________
217 void AliITSCalibrationSDD::GiveCompressParam(Int_t cp[8],Int_t ian) const {
219 // give compression param
223 cp[0]=(Int_t) fBaseline[ian];
225 cp[1]=(Int_t) fBaseline[ian];
227 cp[2]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
229 cp[3]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
241 //_____________________________________________________________________
243 void AliITSCalibrationSDD::SetBadChannel(Int_t i,Int_t anode){
245 //Set bad anode (set gain=0 for these channels);
249 if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
255 chip=anode/fgkChannels;
257 channel=anode-(chip*fgkChannels);
259 if(anode>=fgkChips*fgkChannels) wing=1;
261 if(wing==1)chip-=fgkChips;
263 fBadChannels[i]=anode;
265 fGain[wing][chip][channel]=0;
269 //_____________________________________________________________________
271 Bool_t AliITSCalibrationSDD::IsBadChannel(Int_t anode){
273 //returns kTRUE if the anode i (0-512) has fGain=0
275 if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
281 chip=anode/fgkChannels;
283 channel=anode-(chip*fgkChannels);
285 if(anode>=fgkChips*fgkChannels) wing=1;
287 if(wing==1)chip-=fgkChips;
289 if(fGain[wing][chip][channel]==0) return kTRUE;
297 //______________________________________________________________________
299 void AliITSCalibrationSDD::SetDeadChannels(Int_t nchip, Int_t nchan){
301 // Set fGain to zero to simulate a random distribution of
303 // dead modules, dead chips and single dead channels
307 for( Int_t m=0; m<fgkWings; m++ )
309 for( Int_t n=0; n<fgkChips; n++ )
311 for( Int_t p=0; p<fgkChannels; p++ )
317 //fDeadModules = nmod;
321 fDeadChannels = nchan;
323 fBadChannels.Set(fDeadChannels);
327 //if( nmod == 0 && nchip == 0 && nchan == 0 ) return;
331 if( nchip == 0 && nchan == 0 ) return;
333 // if( nmod < 0 || nmod > fgkModules )
337 // cout << "Wrong number of dead modules: " << nmod << endl;
345 Int_t nmax = fgkWings*fgkChips;
347 if( nchip < 0 || nchip > nmax )
351 cout << "Wrong number of dead chips: " << nchip << endl;
357 nmax = (fgkWings*fgkChips - nchip)*fgkChannels;
359 if( nchan < 0 || nchan > nmax )
363 cout << "Wrong number of dead channels: " << nchan << endl;
371 TRandom *gran = new TRandom();
373 // cout << "chips" << endl;
375 Int_t * chip = new Int_t[nchip];
383 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
385 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing");
389 Int_t chi = (Int_t) (fgkChips*gran->Uniform() + 1.);
391 if( chi <=0 || chi > fgkChips ) Error("SetDeadChannels","Wrong chip:%d\n",chi);
397 for( Int_t m=0; m<fgkChannels; m++ )
399 fGain[wing-1][chi-1][m] = 0.;
405 Int_t * channel = new Int_t[nchan];
407 Int_t * channelChip = new Int_t[nchan];
415 Int_t k; //loop variable
417 Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
419 if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing:%d\n",wing);
421 Int_t chipp = (Int_t) (fgkChips*gran->Uniform() + 1.);
423 if( chipp <=0 || chipp > fgkChips ) Error("SetDeadChannels","Wrong chip:%d",chipp);
427 for( k=0; k<nchip; k++)
429 if( chipp == chip[k] ) {
431 flagChip = 1; break; }
433 if( flagChip == 1 ) continue;
437 channel[i-1] = (Int_t) (fgkChannels*gran->Uniform() + 1.);
439 if( channel[i-1] <=0 || channel[i-1] > fgkChannels )
441 Error("SetDeadChannels","Wrong channel:%d\n",channel[i-1]);
443 channelChip[i-1] = chipp;
445 fGain[wing-1][chipp-1][channel[i-1]-1] = 0.;
455 delete [] channelChip;
461 //______________________________________________________________________
463 void AliITSCalibrationSDD::PrintGains() const{
469 if( GetDeadChips() == 0 &&
471 GetDeadChannels() == 0 )
477 // Print Electronics Gains
479 cout << "**************************************************" << endl;
481 cout << " Print Electronics Gains " << endl;
483 cout << "**************************************************" << endl;
487 // Print SDD electronic gains
489 for(Int_t t=0; t<fgkWings;t++)
491 for(Int_t u=0; u<fgkChips;u++)
493 for(Int_t v=0; v<fgkChannels;v++)
497 if( fGain[t][u][v] != 1.0 )
499 cout << "Gain for wing: " << t+1 << ", Chip " << u+1 <<
501 ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
507 //______________________________________________________________________
509 void AliITSCalibrationSDD::Print(){
511 // Print SDD response Parameters
515 cout << "**************************************************" << endl;
517 cout << " Silicon Drift Detector Response Parameters " << endl;
519 cout << "**************************************************" << endl;
521 cout << "Hardware compression parameters: " << endl;
523 cout << "Noise before electronics (arbitrary units): " << fNoise[0] << endl;
525 cout << "Baseline (ADC units): " << fBaseline[0] << endl;
527 cout << "Noise after electronics (ADC units): " << fNoiseAfterEl[0] << endl;
529 cout << "Temperature: " << Temperature() << " K " << endl;
531 cout << "Min. Value: " << fMinVal << endl;