/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* See cxx source for full Copyright notice */
-/* $Id:$ */
+/* $Id$ */
//////////////////////////////////////////////
// Base ITS calibration class //
// Destructor.
virtual ~AliITSCalibration() {;}
+
+ // Check for dead modules anche chips
+ // Return 1 if the module/chip is dead, 0 if it is ok
+ virtual Bool_t IsBad() const {AliError("This method must be implemented in a derived class"); return kFALSE;}
+ virtual Bool_t IsChipBad(Int_t) const {AliError("This method must be implemented in a derived class"); return kFALSE;}
//
// Configuration methods
//
fDeadChips(0),
fDeadChannels(0),
fMinVal(fgkMinValDefault),
-fIsDead(kFALSE),
+fIsBad(kFALSE),
fBadChannels(),
fUseACorrMap(0),
fUseTCorrMap(0),
for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
fBaseline[ian]=fgkBaselineDefault;
fNoise[ian]=fgkNoiseDefault;
+ fGain[ian]=1.;
SetNoiseAfterElectronics(ian);
}
for(Int_t iw=0;iw<fgkWings;iw++){
for(Int_t icp=0;icp<fgkChips;icp++){
- for(Int_t ich=0;ich<fgkChannels;ich++)
- fGain[iw][icp][ich]=1.;
+ Int_t chipindex=iw*fgkChips+icp;
+ fIsChipBad[chipindex]=kFALSE;
}
}
SetThresholds(fgkMinValDefault,0.);
fDeadChips(0),
fDeadChannels(0),
fMinVal(fgkMinValDefault),
-fIsDead(kFALSE),
+fIsBad(kFALSE),
fBadChannels(),
fUseACorrMap(0),
fUseTCorrMap(0),
SetDeadChannels();
for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
fBaseline[ian]=fgkBaselineDefault;
- fNoise[ian]=fgkNoiseDefault;
- SetNoiseAfterElectronics(ian);
+ fNoise[ian]=fgkNoiseDefault;
+ fGain[ian]=1.;
+ SetNoiseAfterElectronics(ian);
}
for(Int_t iw=0;iw<fgkWings;iw++){
for(Int_t icp=0;icp<fgkChips;icp++){
- for(Int_t ich=0;ich<fgkChannels;ich++)
- fGain[iw][icp][ich]=1.;
+ Int_t chipindex=iw*fgkChips+icp;
+ fIsChipBad[chipindex]=kFALSE;
}
}
//Set bad anode (set gain=0 for these channels);
if(anode<0 || anode >fgkChannels*fgkChips*fgkWings-1)AliError("Wrong anode number");
- Int_t wing=0;
- Int_t chip,channel;
- chip=anode/fgkChannels;
- channel=anode-(chip*fgkChannels);
- if(anode>=fgkChips*fgkChannels) wing=1;
- if(wing==1)chip-=fgkChips;
fBadChannels[i]=anode;
- fGain[wing][chip][channel]=0;
-}
-//______________________________________________________________________
-Float_t AliITSCalibrationSDD::GetChannelGain(Int_t anode) const{
- // returns gain for givenanode
- Int_t iWing=GetWing(anode);
- Int_t iChip=GetChip(anode);
- Int_t iChan=GetChipChannel(anode);
- return fGain[iWing][iChip][iChan];
+ fGain[anode]=0;
}
//______________________________________________________________________
void AliITSCalibrationSDD::GetCorrections(Float_t z, Float_t x, Float_t &devz, Float_t &devx, AliITSsegmentationSDD* seg){
}
return;
}
-/*
-//______________________________________________________________________
-void AliITSCalibrationSDD::SetDeadChannels(Int_t nchip, Int_t nchan){
- // Set fGain to zero to simulate a random distribution of
- // dead modules, dead chips and single dead channels
-
- for( Int_t m=0; m<fgkWings; m++ )
- for( Int_t n=0; n<fgkChips; n++ )
- for( Int_t p=0; p<fgkChannels; p++ )
- fGain[m][n][p] = 1.;
-
- //fDeadModules = nmod;
- fDeadChips = nchip;
- fDeadChannels = nchan;
- fBadChannels.Set(fDeadChannels);
- // nothing to do
- //if( nmod == 0 && nchip == 0 && nchan == 0 ) return;
-
- if( nchip == 0 && nchan == 0 ) return;
- // if( nmod < 0 || nmod > fgkModules )
- // {
- // cout << "Wrong number of dead modules: " << nmod << endl;
- // return;
- // }
-
- Int_t nmax = fgkWings*fgkChips;
- if( nchip < 0 || nchip > nmax )
- {
- cout << "Wrong number of dead chips: " << nchip << endl;
- return;
- }
- nmax = (fgkWings*fgkChips - nchip)*fgkChannels;
- if( nchan < 0 || nchan > nmax )
- {
- cout << "Wrong number of dead channels: " << nchan << endl;
- return;
- }
-
- TRandom *gran = new TRandom();
- // cout << "chips" << endl;
- Int_t * chip = new Int_t[nchip];
- Int_t i = 0;
- while( i < nchip )
- {
- Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
- if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing");
-
- Int_t chi = (Int_t) (fgkChips*gran->Uniform() + 1.);
- if( chi <=0 || chi > fgkChips ) Error("SetDeadChannels","Wrong chip:%d\n",chi);
- i++;
- chip[i-1] = chi;
- for( Int_t m=0; m<fgkChannels; m++ )
- fGain[wing-1][chi-1][m] = 0.;
- }
-
- Int_t * channel = new Int_t[nchan];
- Int_t * channelChip = new Int_t[nchan];
- i = 0;
- while( i < nchan )
- {
- Int_t k; //loop variable
- Int_t wing = (Int_t) (fgkWings*gran->Uniform() + 1.);
- if( wing <=0 || wing > fgkWings ) Error("SetDeadChannels","Wrong wing:%d\n",wing);
- Int_t chipp = (Int_t) (fgkChips*gran->Uniform() + 1.);
- if( chipp <=0 || chipp > fgkChips ) Error("SetDeadChannels","Wrong chip:%d",chipp);
- Int_t flagChip = 0;
- for( k=0; k<nchip; k++)
- if( chipp == chip[k] ) {
- flagChip = 1; break; }
- if( flagChip == 1 ) continue;
- i++;
- channel[i-1] = (Int_t) (fgkChannels*gran->Uniform() + 1.);
- if( channel[i-1] <=0 || channel[i-1] > fgkChannels )
- Error("SetDeadChannels","Wrong channel:%d\n",channel[i-1]);
- channelChip[i-1] = chipp;
- fGain[wing-1][chipp-1][channel[i-1]-1] = 0.;
- }
-
- delete [] chip;
- delete [] channel;
- delete [] channelChip;
-}
-*/
-
-
//______________________________________________________________________
void AliITSCalibrationSDD::PrintGains() const{
//
cout << "**************************************************" << endl;
// Print SDD electronic gains
- for(Int_t t=0; t<fgkWings;t++)
- for(Int_t u=0; u<fgkChips;u++)
- for(Int_t v=0; v<fgkChannels;v++)
- {
- if( fGain[t][u][v] != 1.0 )
- cout << "Gain for wing: " << t+1 << ", Chip " << u+1 <<
- ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
- }
+ for(Int_t ian=0; ian<fgkWings*fgkChips*fgkChannels;ian++){
+ printf("Gain for channel %d = %f\n",ian,fGain[ian]);
+ }
}
//______________________________________________________________________
void SetDeadChannels(Int_t ndead=0){fDeadChannels=ndead; fBadChannels.Set(ndead);}
Int_t GetDeadChips() const { return fDeadChips; }
Int_t GetDeadChannels() const { return fDeadChannels; }
- Float_t Gain(Int_t wing,Int_t chip,Int_t ch)const
- {return fGain[wing][chip][ch]; }
- Float_t GetChannelGain(Int_t anode) const;
- virtual void SetGain(Double_t g,Int_t wing,Int_t chip, Int_t ch)
- {fGain[wing][chip][ch]=g;}
+ Float_t GetChannelGain(Int_t anode) const {return fGain[anode];}
+ virtual void SetGain(Int_t anode,Double_t g){fGain[anode]=g;}
+
Int_t GetWing(Int_t anode) const{
if(anode>=fgkChips*fgkChannels) return 1;
else return 0;
}
Int_t GetChipChannel(Int_t anode) const {return anode%fgkChannels;}
- Int_t GetChip(Int_t anode) const {
- Int_t chip=anode/fgkChannels;
- if(GetWing(anode)==1)chip-=fgkChips;
- return chip;
+ Int_t GetChip(Int_t anode) const {return anode/fgkChannels;}
+ Int_t GetAnodeNumber(Int_t iwing, Int_t ichip03, Int_t ichan) const {
+ if(iwing>=2 || ichip03>=4 || ichan>=64) return -1;
+ else return iwing*fgkChips*fgkChannels+ichip03*fgkChannels+ichan;
+ }
+ Int_t GetAnodeNumber(Int_t ichip07, Int_t ichan) const {
+ if(ichip07>=8 || ichan>=64) return -1;
+ else return ichip07*fgkChannels+ichan;
}
void PrintGains() const;
virtual void SigmaSpread(Double_t & /* p1 */,Double_t & /* p2 */) const
{NotImplemented("SigmaSpread");}
- void SetDead() { fIsDead = kTRUE; };
- Bool_t IsDead() const { return fIsDead; };
+ void SetBad() {
+ fIsBad = kTRUE;
+ for(Int_t i=0;i<fgkChips*fgkWings;i++) fIsChipBad[i]=kTRUE;
+ }
+ virtual Bool_t IsBad() const { return fIsBad; }
+ void SetChipBad(Int_t nChip) {
+ fIsChipBad[nChip] = kTRUE;
+ }
+ virtual Bool_t IsChipBad(Int_t nChip) const {
+ return fIsChipBad[nChip];
+ }
Int_t Wings()const{return fgkWings;}//Total number of SDD wings
Int_t Chips() const{return fgkChips;} // Number of chips/module
Int_t Channels() const{ return fgkChannels;}//Number of channels/chip
Int_t fDeadChips; // Number of dead chips
Int_t fDeadChannels; // Number of dead channels
- Float_t fGain[fgkWings][fgkChips][fgkChannels];//Array for channel gains
+ Float_t fGain[fgkWings*fgkChips*fgkChannels]; //Array for channel gains
Float_t fNoise[fgkWings*fgkChips*fgkChannels]; // Noise array
Float_t fBaseline[fgkWings*fgkChips*fgkChannels]; // Baseline array
Float_t fNoiseAfterEl[fgkWings*fgkChips*fgkChannels]; // Noise after electronics
Float_t fMinVal; // Min value used in 2D zero-suppression algo
- Bool_t fIsDead; // module is dead or alive ?
- TArrayI fBadChannels; //Array with bad anodes number (0-512)
+ Bool_t fIsBad; // module is dead or alive ?
+ Bool_t fIsChipBad[fgkWings*fgkChips]; // chip is dead or alive ?
+ TArrayI fBadChannels; //Array with bad anodes number (0-512)
Bool_t fUseACorrMap; // flag for the use of correction maps (anode)
AliITSCalibrationSDD& operator=(const AliITSCalibrationSDD & /* source */); // ass. op.
- ClassDef(AliITSCalibrationSDD,9) // SDD response
+ ClassDef(AliITSCalibrationSDD,10) // SDD response
};
#endif
void SetBadList(TArrayI badlist) {fBadChannels=badlist;}
void SetNrBad(UInt_t nr) {fNrBad=nr;}
- Bool_t IsBad() const {return (GetNrBad()==256*160);};
+ virtual Bool_t IsBad() const {return (GetNrBad()==256*160);};
protected:
// static const Double_t fgkDiffCoeffDefault; //default for fDiffCoeff
FILE* basFil = fopen(inpFileName,"read");
if (basFil == 0) {
Log(Form("File %s not found.",inpFileName));
- cal->SetDead();
- continue;
+ return 2;
}
fscanf(basFil,"%d %d %d\n",&im,&is,&isgoodmod);
- if(!isgoodmod) cal->SetDead();
+ if(!isgoodmod) cal->SetBad();
for(Int_t ian=0;ian<(kNumberOfChannels/2);ian++){
fscanf(basFil,"%d %d %f %d %d %f %f %f %f\n",&i,&isgoodan,&baseline,&basmin,&basoff,&rawnoise,&cmn,&corn,&gain);
Int_t ich=ian;
}
cal->SetBaseline(ich,baseline);
cal->SetNoiseAfterElectronics(ich,rawnoise);
- Int_t iChip=cal->GetChip(ich);
- Int_t iChInChip=cal->GetChipChannel(ich);
- cal->SetGain(gain,isid,iChip,iChInChip);
+ cal->SetGain(ich,gain);
}
cal->SetDeadChannels(numOfBadChannels[modID]);
for(Int_t ibad=0;ibad<numOfBadChannels[modID];ibad++){
}
md1->SetObjectClassName("AliITSCalibration");
retcode = Store("Calib","CalibSDD",&calSDD,md1, 0, kTRUE);
- }else if(runType== "INJECTOR"){
+ }else if(runType == "PHYSICS" || runType== "INJECTOR"){
TObjArray vdrift(2*kNumberOfSDD);
vdrift.SetOwner(kFALSE);
FILE* injFil = fopen(inpFileName,"read");
if (injFil == 0) {
Log(Form("File %s not found.",inpFileName));
- AliITSDriftSpeedSDD *dsp=new AliITSDriftSpeedSDD();
- arr->AddDriftSpeed(dsp);
- vdrift.AddAt(arr,2*modID+isid);
- continue;
+ return 2;
}
fscanf(injFil,"%d",&polDeg);
while (!feof(injFil)){
baseline = res->GetBaseline(i);
noise = res->GetNoise(i);
gain = res->GetChannelGain(i);
- if(res->IsDead()) gain=0;
+ if(res->IsBad()) gain=0.;
+ if( res->IsChipBad(res->GetChip(i)) ){
+ printf("Chip bad mod %d chip %d anode %d\n",mod,res->GetChip(i),i);
+ gain=0.;
+ }
for(k=0; k<fScaleSize*fMaxNofSamples; k++) {
fInZR[k] = fHitMap2->GetSignal(i,k);
if(bAddGain) fInZR[k]*=gain;
if(ilayer==3) idet += AliITSgeomTGeo::GetNLadders(3)*AliITSgeomTGeo::GetNDetectors(3);
//printf("SDD det: %d\n",idet);
AliITSCalibrationSDD *calibSDD = (AliITSCalibrationSDD*)sddEntry->At(idet);
- if (calibSDD->IsDead()) return 2;
+ if (calibSDD->IsBad()) return 2;
} else if (ilayer==4 || ilayer==5) { // SSD
} else {
Error("CheckDeadZone","Wrong layer number\n");
#include <TRandom3.h>
#endif
-void StoreCalibSDD(Int_t firstRun=0,Int_t lastRun=9999999 ){
+void StoreCalibSDD(Int_t firstRun=0,Int_t lastRun=9999999, Int_t lastRunResp=999999999 ){
///////////////////////////////////////////////////////////////////////
// Macro to generate and store the calibration files for SDD //
// Generates: //
- AliCDBId idRespSDD("ITS/Calib/RespSDD",firstRun, lastRun);
+ AliCDBId idRespSDD("ITS/Calib/RespSDD",firstRun, lastRunResp);
AliITSresponseSDD* rd = new AliITSresponseSDD();
const Int_t nData = 209;
Int_t anodeUp[209] = {0,36,0,12,20,32,0,0,12,76,28,8,16,0,0,0,8,0,0,0,20,4,0,0,0,0,0,0
,16,0,16,20,0,28,0,8,24,0,12,8,4,40,0,104,96,32,140,20,12,8,20,24,16,16,20
,8,140,96,0,32,20,44};
-
- Float_t drVelParam[4]={7.75,0.002344,-0.000009,0};
- Float_t edrVelParam[4]={0,0,0,0};
- Float_t drVel[4];
TRandom3 *gran = new TRandom3();
for(Int_t mod=0;mod<260;mod++){
for(Int_t iChan=0; iChan<64;iChan++){
Float_t gain=gran->Gaus(chipgain,0.01);
if(gain<0.1) gain=0.1;
- resd->SetGain(gain,iWing,iChip,iChan);
+ Int_t ian=resd->GetAnodeNumber(iWing,iChip,iChan);
+ resd->SetGain(ian,gain);
}
}
}
Int_t nSeToBad = 0;
for (Int_t i=0; i<4; i++){
for(Int_t j=0;j<64;j++){
- if (resd->Gain(0,i,j)<0.0001) nSeToBad++;
+ Int_t ian=resd->GetAnodeNumber(0,i,j);
+ if (resd->GetChannelGain(ian)<0.0001) nSeToBad++;
}
}
while (nSeToBad<nBadDown) {
nSeToBad = 0;
for (Int_t i=0; i<4; i++){
for(Int_t j=0;j<64;j++){
- if (resd->Gain(1,i,j)<0.0001) nSeToBad++;
+ Int_t ian=resd->GetAnodeNumber(1,i,j);
+ if (resd->GetChannelGain(ian)<0.0001) nSeToBad++;
}
}
*/
- if(mod==88) resd->SetDead();
+ if(mod==88) resd->SetBad();
+ if(mod==202) for(Int_t ichip=0;ichip<4;ichip++) resd->SetChipBad(ichip);
respSDD.Add(resd);
printf("Added module %d\n",mod);
}