]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSresponseSDD.cxx
Transition to NewIO
[u/mrichter/AliRoot.git] / ITS / AliITSresponseSDD.cxx
index 80e982d3489ae72d482f4c5d482af133a3d165b4..33130777e112d7bd2d3ce31b717e338ebae9bae8 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- *                                                                         *
+ *                                                                        *
  * Author: The ALICE Off-line Project.                                    *
  * Contributors are mentioned in the code where appropriate.              *
  *                                                                        *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-#include <TMath.h>
+/* $Id$ */
+
+#include <TString.h>
+#include <TRandom.h>
 
-#include "AliITSgeom.h"
 #include "AliITSresponseSDD.h"
-#include "AliITS.h"
-#include "AliRun.h"
 
-class AliITS;
 
-//___________________________________________
-ClassImp(AliITSresponseSDD)    
+//______________________________________________________________________
+ClassImp(AliITSresponseSDD)
 
-AliITSresponseSDD::AliITSresponseSDD()
-{
-  // constructor
+AliITSresponseSDD::AliITSresponseSDD(){
+  // default constructor
+   fGaus = 0;
+   SetDeadChannels();
    SetMaxAdc();
    SetDiffCoeff();
-   SetQref();
    SetDriftSpeed();
+   SetNSigmaIntegration();
+   SetNLookUp();
    // SetClock();
    SetNoiseParam();
-   SetMagicValue();
+   SetNoiseAfterElectronics();
+   SetJitterError();
+   SetElectronics();
+   SetDynamicRange();
+   SetChargeLoss();
    SetMinVal();
    SetParamOptions();
+   SetTemperature();
    SetZeroSupp();
    SetDataType();
    SetFilenames();
    SetOutputOption();
-
+   SetDo10to8();
+   // set the default zero suppression parameters
+   fCPar[0]=0;
+   fCPar[1]=0;
+   fCPar[2]=(Int_t)(fBaseline + 2.*fNoiseAfterEl + 0.5);
+   fCPar[3]=(Int_t)(fBaseline + 2.*fNoiseAfterEl + 0.5);
+   fCPar[4]=0;
+   fCPar[5]=0;
+   fCPar[6]=0;
+   fCPar[7]=0;
 }
-
-//__________________________________________________________________________
-AliITSresponseSDD::AliITSresponseSDD(const AliITSresponseSDD &source){
-  //     Copy Constructor 
-  Int_t i;
-  if(&source == this) return;
-  for(i=0;i<8;i++){this->fCPar[i] = source.fCPar[i];}
-  this->fNoise = source.fNoise;
-  this->fBaseline = source.fBaseline;
-  this->fTopValue = source.fTopValue;
-  this->fTemperature = source.fTemperature;
-  this->fDriftSpeed = source.fDriftSpeed;
-  this->fMaxAdc = source.fMaxAdc;
-  this->fDiffCoeff = source.fDiffCoeff;
-  this->fQref = source.fQref;
-  this->fZeroSuppFlag = source.fZeroSuppFlag;
-  this->fMinVal = source.fMinVal;
-  this->fWrite = source.fWrite;
-  this->fOption = source.fOption;
-  this->fParam1 = source.fParam1;
-  return;
+//______________________________________________________________________
+AliITSresponseSDD::AliITSresponseSDD(const char *dataType){
+  // constructor
+   fGaus = 0;
+   SetDeadChannels();
+   SetMaxAdc();
+   SetDiffCoeff();
+   SetDriftSpeed();
+   SetNSigmaIntegration();
+   SetNLookUp();
+   // SetClock();
+   SetNoiseParam();
+   SetNoiseAfterElectronics();
+   SetJitterError();
+   SetElectronics();
+   SetDynamicRange();
+   SetChargeLoss();
+   SetMinVal();
+   SetParamOptions();
+   SetTemperature();
+   SetZeroSupp();
+   SetDataType(dataType);
+   SetFilenames();
+   SetOutputOption();
+   SetDo10to8();
+   // set the default zero suppression parameters
+   fCPar[0]=0;
+   fCPar[1]=0;
+   fCPar[2]=(Int_t)(fBaseline + 2.*fNoiseAfterEl + 0.5);
+   fCPar[3]=(Int_t)(fBaseline + 2.*fNoiseAfterEl + 0.5);
+   fCPar[4]=0;
+   fCPar[5]=0;
+   fCPar[6]=0;
+   fCPar[7]=0;
 }
+//______________________________________________________________________
+AliITSresponseSDD::~AliITSresponseSDD() { 
 
-//_________________________________________________________________________
-AliITSresponseSDD& 
-  AliITSresponseSDD::operator=(const AliITSresponseSDD &source) {
-  //    Assignment operator
-  Int_t i;
-  if(&source == this) return *this;
-  for(i=0;i<8;i++){this->fCPar[i] = source.fCPar[i];}
-  this->fNoise = source.fNoise;
-  this->fBaseline = source.fBaseline;
-  this->fTopValue = source.fTopValue;
-  this->fTemperature = source.fTemperature;
-  this->fDriftSpeed = source.fDriftSpeed;
-  this->fMaxAdc = source.fMaxAdc;
-  this->fDiffCoeff = source.fDiffCoeff;
-  this->fQref = source.fQref;
-  this->fZeroSuppFlag = source.fZeroSuppFlag;
-  this->fMinVal = source.fMinVal;
-  this->fWrite = source.fWrite;
-  this->fOption = source.fOption;
-  this->fParam1 = source.fParam1;
-  return *this;
+  if(fGaus) delete fGaus;
 }
-
-void AliITSresponseSDD::SetCompressParam(Int_t  cp[8])
-{
+//______________________________________________________________________
+void AliITSresponseSDD::SetCompressParam(Int_t  cp[8]){
   // set compression param
+
     Int_t i;
-    for(i=0; i<8; i++) {
-       fCPar[i]=cp[i];
-       //printf("\n CompressPar %d %d \n",i,fCPar[i]);
-       
-    }
+    for (i=0; i<8; i++) {
+        fCPar[i]=cp[i];
+        //printf("\n CompressPar %d %d \n",i,fCPar[i]);    
+    } // end for i
 }
-void AliITSresponseSDD::GiveCompressParam(Int_t  cp[8])
-{
+//______________________________________________________________________
+void AliITSresponseSDD::GiveCompressParam(Int_t  cp[8]){
   // give compression param
+
     Int_t i;
-    for(i=0; i<8; i++) {
-       cp[i]=fCPar[i];
+    for (i=0; i<8; i++) {
+        cp[i]=fCPar[i];
+    } // end for i
+}
+//______________________________________________________________________
+void AliITSresponseSDD::SetDeadChannels(Int_t nmod, 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<fModules; m++ ) 
+        for( Int_t n=0; n<fChips; n++ ) 
+            for( Int_t p=0; p<fChannels; p++ ) 
+                 fGain[m][n][p] = 1.;
+                 
+    fDeadModules  = nmod;  
+    fDeadChips    = nchip;  
+    fDeadChannels = nchan; 
+    
+    // nothing to do
+    if( nmod == 0 && nchip == 0 && nchan == 0 ) return;
+
+    if( nmod < 0 || nmod > fModules ) 
+    { 
+        cout << "Wrong number of dead modules: " << nmod << endl; 
+        return; 
+    }
+    Int_t nmax = (fModules-nmod)*fChips; 
+    if( nchip < 0 || nchip > nmax ) 
+    { 
+        cout << "Wrong number of dead chips: " << nchip << endl; 
+        return; 
+    }
+    nmax = ((fModules - nmod)*fChips - nchip)*fChannels; 
+    if( nchan < 0 || nchan > nmax ) 
+    { 
+        cout << "Wrong number of dead channels: " << nchan << endl; 
+        return; 
+    }
+  
+    TRandom *gran = new TRandom();
+  
+    //  cout << "modules" << endl;
+    Int_t * mod = new Int_t [nmod];
+    Int_t i; //loop variable
+    for( i=0; i<nmod; i++ ) 
+    {
+        mod[i] = (Int_t) (1.+fModules*gran->Uniform());
+        cout << i+1 << ": Dead module nr: " << mod[i] << endl;
+        for(Int_t n=0; n<fChips; n++)
+            for(Int_t p=0; p<fChannels; p++)
+                fGain[mod[i]-1][n][p] = 0.;
+    }
+
+    //  cout << "chips" << endl;
+    Int_t * chip     = new Int_t[nchip];
+    Int_t * chip_mod = new Int_t[nchip];
+    i = 0;
+    while( i < nchip ) 
+    {
+        Int_t module = (Int_t) (fModules*gran->Uniform() + 1.);
+        if( module <=0 || module > fModules ) 
+            cout << "Wrong module: " << module << endl;
+        Int_t flag_mod = 0;
+        for( Int_t k=0; k<nmod; k++ ) 
+            if( module == mod[k] ) { flag_mod = 1; break; }
+        if( flag_mod == 1 ) continue;
+        
+        Int_t chi = (Int_t) (fChips*gran->Uniform() + 1.);
+        if( chi <=0 || chi > fChips ) cout << "Wrong chip: " << chi << endl;
+        i++;
+        chip[i-1] = chi; 
+        chip_mod[i-1] = module;
+        for( Int_t m=0; m<fChannels; m++ ) 
+            fGain[module-1][chi-1][m] = 0.;
+        cout << i << ": Dead chip nr. " << chip[i-1] << " in module nr: " 
+            << chip_mod[i-1] << endl;
     }
+
+    //  cout << "channels" << endl;
+    Int_t * channel      = new Int_t[nchan];
+    Int_t * channel_chip = new Int_t[nchan];
+    Int_t * channel_mod  = new Int_t[nchan];
+    i = 0;
+    while( i < nchan ) 
+    {
+        Int_t k; //loop variable
+        Int_t module = (Int_t) (fModules*gran->Uniform() + 1.);
+        if( module <=0 || module > fModules ) 
+            cout << "Wrong module: " << module << endl;
+        Int_t flag_mod = 0;
+        for( k=0; k<nmod; k++ ) 
+            if( module == mod[k] ) { flag_mod = 1; break; }
+        if( flag_mod == 1 ) continue;
+        Int_t chipp = (Int_t) (fChips*gran->Uniform() + 1.);
+        if( chipp <=0 || chipp > fChips ) cout << "Wrong chip: "<< chipp<<endl;
+        Int_t flag_chip = 0;
+        for( k=0; k<nchip; k++) 
+            if( chipp == chip[k] && module == chip_mod[k] ) { 
+               flag_chip = 1; break; }
+        if( flag_chip == 1 ) continue;
+        i++;
+        channel[i-1] = (Int_t) (fChannels*gran->Uniform() + 1.); 
+        if( channel[i-1] <=0 || channel[i-1] > fChannels ) 
+            cout << "Wrong channel: " << channel[i-1] << endl;
+        channel_chip[i-1] = chipp;
+        channel_mod[i-1] = module;
+        fGain[module-1][chipp-1][channel[i-1]-1] = 0.;
+        cout << i << ": Dead channel nr. " << channel[i-1] << " in chip nr. " 
+            << channel_chip[i-1] << " in module nr: " << channel_mod[i-1] 
+            << endl;
+    }
+    
+    delete [] mod;
+    delete [] chip;
+    delete [] chip_mod;
+    delete [] channel;
+    delete [] channel_mod;
+    delete [] channel_chip;
+}
+//______________________________________________________________________
+void AliITSresponseSDD::PrintGains(){
+    //
+
+  if( GetDeadModules() == 0 && 
+      GetDeadChips() == 0 && 
+      GetDeadChannels() == 0 )
+      return;  
+
+  // Print Electronics Gains
+  cout << "**************************************************" << endl; 
+  cout << "             Print Electronics Gains              " << endl;
+  cout << "**************************************************" << endl;
+
+  // Print SDD electronic gains
+  for(Int_t t=0; t<fModules;t++)
+    for(Int_t u=0; u<fChips;u++)
+      for(Int_t v=0; v<fChannels;v++)
+      {
+        if( fGain[t][u][v] != 1.0 )
+           cout << "Gain for Module: " << t+1 << ", Chip " << u+1 << 
+                   ", Channel " << v+1 << " = " << fGain[t][u][v] << endl;
+      }
 }
-//______________________________________________________________________________
-void AliITSresponseSDD::Streamer(TBuffer &R__b)
-{
-   // Stream an object of class AliITSresponseSDD.
-
-   if (R__b.IsReading()) {
-      Version_t R__v = R__b.ReadVersion(); if (R__v) { }
-      AliITSresponse::Streamer(R__b);
-      R__b.ReadStaticArray(fCPar);
-      R__b >> fNoise;
-      R__b >> fBaseline;
-      R__b >> fTopValue;
-      R__b >> fTemperature;
-      R__b >> fDriftSpeed;
-      R__b >> fMaxAdc;
-      R__b >> fDiffCoeff;
-      R__b >> fQref;
-      R__b >> fZeroSuppFlag;
-      R__b >> fMinVal;
-      R__b >> fWrite;
-      //R__b.ReadArray(fOption); // Not to be printed out?
-      //R__b.ReadArray(fParam1); // Not to be printed out?
-      //R__b.ReadArray(fParam2); // Not to be printed out?
-      fDataType.Streamer(R__b);
-      fFileName1.Streamer(R__b);
-      fFileName2.Streamer(R__b);
-      fFileName3.Streamer(R__b);
-   } else {
-      R__b.WriteVersion(AliITSresponseSDD::IsA());
-      AliITSresponse::Streamer(R__b);
-      R__b.WriteArray(fCPar, 8);
-      R__b << fNoise;
-      R__b << fBaseline;
-      R__b << fTopValue;
-      R__b << fTemperature;
-      R__b << fDriftSpeed;
-      R__b << fMaxAdc;
-      R__b << fDiffCoeff;
-      R__b << fQref;
-      R__b << fZeroSuppFlag;
-      R__b << fMinVal;
-      R__b << fWrite;
-      //R__b.WriteArray(fOption, __COUNTER__); // Not to be printed out?
-      //R__b.WriteArray(fParam1, __COUNTER__); // Not to be printed out?
-      //R__b.WriteArray(fParam2, __COUNTER__); // Not to be printed out?
-      fDataType.Streamer(R__b);
-      fFileName1.Streamer(R__b);
-      fFileName2.Streamer(R__b);
-      fFileName3.Streamer(R__b);
-   }
+//______________________________________________________________________
+void AliITSresponseSDD::Print(){
+  // Print SDD response Parameters
+
+   cout << "**************************************************" << endl;
+   cout << "   Silicon Drift Detector Response Parameters    " << endl;
+   cout << "**************************************************" << endl;
+   cout << "Diffusion Coefficients: "<< fDiffCoeff<< ", "<<fDiffCoeff1 << endl;
+
+   cout << "Hardware compression parameters: " << endl; 
+   for(Int_t i=0; i<8; i++) cout << "fCPar[" << i << "] = " << fCPar[i] <<endl;
+   cout << "Noise before electronics (arbitrary units): " << fNoise << endl;
+   cout << "Baseline (ADC units): " << fBaseline << endl;
+   cout << "Noise after electronics (ADC units): " << fNoiseAfterEl << endl;
+
+   cout << "Dynamic Range: " << fDynamicRange << endl;
+   cout << "Charge Loss: " << fChargeLoss << endl;
+   cout << "Temperature: " << fTemperature << endl;
+   cout << "Drift Speed: " << fDriftSpeed << endl;
+   cout << "Electronics (1=PASCAL, 2=OLA): " << fElectronics << endl;
+
+   cout << "N. of Sigma for signal integration: " << fNsigmas << endl;
+   cout << "N. of bins in lookup table: " << fNcomps << endl;
+
+   cout << "Max. ADC Value: " << fMaxAdc << endl;
+   cout << "Min. Value: " << fMinVal << endl;
+
+   PrintGains();
+
 }
+
+
+