/*
$Log$
+Revision 1.1 2005/10/11 12:31:50 masera
+Preprocessor classes for SPD (Paul Nilsson)
+
*/
///////////////////////////////////////////////////////////////////////////
// The signal member of the digit is not a member of the channel class.
// It is artificially introduced by the CreateDigitFromChannel method and
// is per default set to 1.
+//
+// Modified by D. Elia, H. Tydesjo
+// March 2006: Mixed up coordinates, bug fixed
+//
///////////////////////////////////////////////////////////////////////////
#include "AliITSBadChannelsAuxSPD.h"
const Int_t kN = array->GetEntries();
Int_t channelNr = 0;
Int_t column = digit->GetCoord1();
- Int_t row = digit->GetCoord1();
+ Int_t row = digit->GetCoord2();
// Loop over all channels in the array
while (channelNr < kN)
/**************************************************************************
+
* 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. *
+
* *
+
* Permission to use, copy, modify and distribute this software and its *
+
* documentation strictly for non-commercial purposes is hereby granted *
+
* without fee, provided that the above copyright notice appears in all *
+
* copies and that both the copyright notice and this permission notice *
+
* appear in the supporting documentation. The authors make no claims *
+
* about the suitability of this software for any purpose. It is *
+
* provided "as is" without express or implied warranty. *
+
**************************************************************************/
+
+
+
#include <Riostream.h>
+
#include <TRandom.h>
+
#include "AliITSCalibrationSDD.h"
+
#include "AliLog.h"
+
+
//////////////////////////////////////////////////////
+
// Calibration class for set:ITS //
+
// Specific subdetector implementation //
+
// for silicon drift detectors //
+
// //
+
// //
+
//////////////////////////////////////////////////////
+
+
const Double_t AliITSCalibrationSDD::fgkTemperatureDefault = 296.;
+
const Double_t AliITSCalibrationSDD::fgkNoiseDefault = 10.;
+
const Double_t AliITSCalibrationSDD::fgkGainDefault = 1.;
+
const Double_t AliITSCalibrationSDD::fgkBaselineDefault = 20.;
+
const Double_t AliITSCalibrationSDD::fgkMinValDefault = 4;
+
//______________________________________________________________________
+
ClassImp(AliITSCalibrationSDD)
+
+
AliITSCalibrationSDD::AliITSCalibrationSDD(){
+
// default constructor
+
+
SetDeadChannels();
+
fBadChannels.Set(fDeadChannels);
+
for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
+
fBaseline[ian]=fgkBaselineDefault;
+
fNoise[ian]=fgkNoiseDefault;
+
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.;
+
}
+
}
+
SetThresholds(fgkMinValDefault,0.);
+
SetTemperature(fgkTemperatureDefault);
+
SetDataType();
+
+ for(Int_t i=0;i<fgkChips*fgkChannels;i++){
+
+ for(Int_t j=0;j<fgkMapTimeNBin;j++){
+
+ fMapA[i][j]=0;
+
+ fMapT[i][j]=0;
+
+ }
+
+ }
+
}
+
//______________________________________________________________________
+
AliITSCalibrationSDD::AliITSCalibrationSDD(const char *dataType){
+
// constructor
+
+
SetDeadChannels();
+
fBadChannels.Set(fDeadChannels);
+
for(Int_t ian=0;ian<fgkWings*fgkChannels*fgkChips;ian++){
+
fBaseline[ian]=fgkBaselineDefault;
+
fNoise[ian]=fgkNoiseDefault;
+
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.;
+
}
+
}
+
+
SetThresholds(fgkMinValDefault,0.);
+
SetTemperature(fgkTemperatureDefault);
+
SetDataType(dataType);
+
+ for(Int_t i=0;i<fgkChips*fgkChannels;i++){
+
+ for(Int_t j=0;j<fgkMapTimeNBin;j++){
+
+ fMapA[i][j]=0;
+
+ fMapT[i][j]=0;
+
+ }
+
+ }
+
+
+
}
+
//______________________________________________________________________
+
AliITSCalibrationSDD::AliITSCalibrationSDD(const AliITSCalibrationSDD &ob) : AliITSCalibration(ob) {
+
// Copy constructor
+
// Copies are not allowed. The method is protected to avoid misuse.
+
Error("AliITSCalibrationSDD","Copy constructor not allowed\n");
+
}
+
+
//______________________________________________________________________
+
AliITSCalibrationSDD& AliITSCalibrationSDD::operator=(const AliITSCalibrationSDD& /* ob */){
+
// Assignment operator
+
// Assignment is not allowed. The method is protected to avoid misuse.
+
Error("= operator","Assignment operator not allowed\n");
+
return *this;
+
}
+
+
//______________________________________________________________________
+
void AliITSCalibrationSDD::GiveCompressParam(Int_t cp[8],Int_t ian) const {
+
// give compression param
+
+
cp[0]=(Int_t) fBaseline[ian];
+
cp[1]=(Int_t) fBaseline[ian];
+
cp[2]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
+
cp[3]=(Int_t)(2.*fNoiseAfterEl[ian] + 0.5);
+
cp[4]=0;
+
cp[5]=0;
+
cp[6]=0;
+
cp[7]=0;
+
}
+
//_____________________________________________________________________
+
void AliITSCalibrationSDD::SetBadChannel(Int_t i,Int_t anode){
+
//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;
+
}
+
//_____________________________________________________________________
+
Bool_t AliITSCalibrationSDD::IsBadChannel(Int_t anode){
+
//returns kTRUE if the anode i (0-512) has fGain=0
+
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;
+
if(fGain[wing][chip][channel]==0) return kTRUE;
+
else return kFALSE;
+
}
+
/*
+
//______________________________________________________________________
+
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{
+
//
+
+
if( 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<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;
+
}
+
}
+
//______________________________________________________________________
+
void AliITSCalibrationSDD::Print(){
+
// Print SDD response Parameters
+
+
cout << "**************************************************" << endl;
+
cout << " Silicon Drift Detector Response Parameters " << endl;
+
cout << "**************************************************" << endl;
+
cout << "Hardware compression parameters: " << endl;
+
cout << "Noise before electronics (arbitrary units): " << fNoise[0] << endl;
+
cout << "Baseline (ADC units): " << fBaseline[0] << endl;
+
cout << "Noise after electronics (ADC units): " << fNoiseAfterEl[0] << endl;
+
cout << "Temperature: " << Temperature() << " K " << endl;
+
cout << "Min. Value: " << fMinVal << endl;
+
PrintGains();
-}
+}
Int_t GetBadChannel(Int_t i) const {return fBadChannels[i];}
Bool_t IsBadChannel(Int_t anode);
+ Float_t GetMapACell(Int_t i,Int_t j) const {return fMapA[i][j];}
+ virtual void SetMapACell(Int_t i,Int_t j,Float_t dev) {fMapA[i][j]=dev;}
+ Float_t GetMapTCell(Int_t i,Int_t j) const {return fMapT[i][j];}
+ virtual void SetMapTCell(Int_t i,Int_t j,Float_t dev) {fMapT[i][j]=dev;}
+ static const Int_t GetMapTimeNBin() {return fgkMapTimeNBin;}
+
virtual void SetElectronics(Int_t p1=1) {((AliITSresponseSDD*)fResponse)->SetElectronics(p1);}
virtual Int_t GetElectronics() const {return ((AliITSresponseSDD*)fResponse)->Electronics();}
virtual void SetMaxAdc(Double_t p1) {((AliITSresponseSDD*)fResponse)->SetMaxAdc(p1);}
virtual Double_t GetJitterError() const {return ((AliITSresponseSDD*)fResponse)->JitterError();}
virtual void SetDo10to8(Bool_t bitcomp=kTRUE) {((AliITSresponseSDD*)fResponse)->SetDo10to8(bitcomp);}
protected:
+
+
// these statis const should be move to AliITSsegmentationSDD
static const Int_t fgkWings = 2; // Number of wings per module
static const Int_t fgkChips = 4; // Number of chips/module
static const Double_t fgkBaselineDefault; // default for fBaseline
static const Double_t fgkMinValDefault; // default for fMinVal
static const Double_t fgkGainDefault; //default for gain
+ static const Int_t fgkMapTimeNBin = 72; //map granularity along drift direction
Int_t fDeadChips; // Number of dead chips
Int_t fDeadChannels; // Number of dead channels
Double_t fGain[fgkWings][fgkChips][fgkChannels];//Array for channel gains
Bool_t fIsDead; // module is dead or alive ?
TArrayI fBadChannels; //Array with bad anodes number (0-512)
+ Float_t fMapA[fgkChips*fgkChannels][fgkMapTimeNBin]; //array with deviations on anode coordinate
+ Float_t fMapT[fgkChips*fgkChannels][fgkMapTimeNBin]; //array with deviations on time coordinate
+
private:
AliITSCalibrationSDD(const AliITSCalibrationSDD &ob); // copy constructor
AliITSCalibrationSDD& operator=(const AliITSCalibrationSDD & /* source */); // ass. op.
- ClassDef(AliITSCalibrationSDD,3) // SDD response
+ ClassDef(AliITSCalibrationSDD,4) // SDD response
};
#endif
* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
-//////////////////////////////////////////////////////
-// Calibration class for set:ITS //
-// Specific subdetector implementation for //
-// Silicon pixels //
-// An alternative version "SPDdubna" //
-// is also available //
-//////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// Calibration class for set:ITS
+// Specific subdetector implementation for
+// Silicon pixels
+//
+// Modified by D. Elia, G.E. Bruno, H. Tydesjo
+// March-April 2006
+//
+///////////////////////////////////////////////////////////////////////////
#include "AliITSCalibrationSPD.h"
-const Double_t AliITSCalibrationSPD::fgkThreshDefault = 2000.;
-const Double_t AliITSCalibrationSPD::fgkSigmaDefault = 280.;
+const Double_t AliITSCalibrationSPD::fgkThreshDefault = 3000.;
+const Double_t AliITSCalibrationSPD::fgkSigmaDefault = 250.;
+const Double_t AliITSCalibrationSPD::fgkCouplColDefault = 0.;
+const Double_t AliITSCalibrationSPD::fgkCouplRowDefault = 0.047;
+const Double_t AliITSCalibrationSPD::fgkBiasVoltageDefault = 18.182;
ClassImp(AliITSCalibrationSPD)
//______________________________________________________________________
fNoise(0.0),
fThresh(fgkThreshDefault),
fSigma(fgkSigmaDefault),
-fDeadPixels(0.01){
+fCouplCol(fgkCouplColDefault),
+fCouplRow(fgkCouplRowDefault),
+fBiasVoltage(fgkBiasVoltageDefault),
+nrDead(0),
+nrNoisy(0){
// constructor
SetThresholds(fgkThreshDefault,fgkSigmaDefault);
+ SetCouplingParam(fgkCouplColDefault,fgkCouplRowDefault);
+ SetBiasVoltage(fgkBiasVoltageDefault);
SetNoiseParam(0.,0.);
SetDataType("simulated");
- SetFractionDead();
}
//_________________________________________________________________________
+
+
+void AliITSCalibrationSPD::AddDead(UInt_t col, UInt_t row) {
+ fDeadChannels.Set(nrDead*2+2);
+ fDeadChannels.AddAt(col,nrDead*2);
+ fDeadChannels.AddAt(row,nrDead*2+1);
+ nrDead++;
+}
+Int_t AliITSCalibrationSPD::GetDeadColAt(UInt_t index) {
+ if (index<nrDead) {
+ return fDeadChannels.At(index*2);
+ }
+ return -1;
+}
+Int_t AliITSCalibrationSPD::GetDeadRowAt(UInt_t index) {
+ if (index<nrDead) {
+ return fDeadChannels.At(index*2+1);
+ }
+ return -1;
+}
+Bool_t AliITSCalibrationSPD::IsPixelDead(Int_t col, Int_t row) const {
+ for (UInt_t i=0; i<nrDead; i++) {
+ if (fDeadChannels.At(i*2)==col && fDeadChannels.At(i*2+1)==row) {
+ return true;
+ }
+ }
+ return false;
+}
+
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+//___________________________________________________________________________
+// THIS METHOD SHOULD BE DELETED AS SOON AS POSSIBLE!!!!!!!!!!!!!!!!!!!!!!!!!
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Bool_t AliITSCalibrationSPD::IsPixelDead(Int_t mod,Int_t ix,Int_t iz) const {
- // Returns kTRUE if pixel is dead
+ // Returns kTRUE if pixel is dead
// Inputs:
// Int_t mod module number
// Int_t ix x pixel number
// none.
// Return:
// kFALSE if pixel is alive, or kTRUE if pixel is dead.
+
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ Double_t fDeadPixels = 0.01; // fix to keep AliITSsimulationSPDdubna alive!!!
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
Bool_t dead = kFALSE;
Int_t seed;
static TRandom ran; // don't use gRandom. This must not be a true randome
if(ran.Rndm(0)<fDeadPixels) dead = kTRUE;
return dead;
}
+//____________________________________________________________________________
+
+void AliITSCalibrationSPD::AddNoisy(UInt_t col, UInt_t row) {
+ fDeadChannels.Set(nrNoisy*2+2);
+ fNoisyChannels.AddAt(col,nrNoisy*2);
+ fNoisyChannels.AddAt(row,nrNoisy*2+1);
+ nrNoisy++;
+}
+Int_t AliITSCalibrationSPD::GetNoisyColAt(UInt_t index) {
+ if (index<nrNoisy) {
+ return fNoisyChannels.At(index*2);
+ }
+ return -1;
+}
+Int_t AliITSCalibrationSPD::GetNoisyRowAt(UInt_t index) {
+ if (index<nrNoisy) {
+ return fNoisyChannels.At(index*2+1);
+ }
+ return -1;
+}
+Bool_t AliITSCalibrationSPD::IsPixelNoisy(Int_t col, Int_t row) const {
+ for (UInt_t i=0; i<nrNoisy; i++) {
+ if (fNoisyChannels.At(i*2)==col && fNoisyChannels.At(i*2+1)==row) {
+ return true;
+ }
+ }
+ return false;
+}
// Get Threshold and noise + threshold fluctuations parameter values
virtual void Thresholds(Double_t &thresh, Double_t &sigma) const
{thresh=fThresh; sigma=fSigma;}
+ // Set Bias Voltage parameter
+ virtual void SetBiasVoltage(Double_t bias=18.182) {fBiasVoltage=bias;}
+ Double_t GetBiasVoltage() const {return fBiasVoltage;}
//Returns just baseline value
Double_t GetBaseline() const {return fBaseline;}
// Set noise and baseline in one (abstract method of AliITSCalibration)
// Applies a random noise and addes the baseline
Double_t ApplyBaselineAndNoise() const {return fBaseline+
fNoise*gRandom->Gaus();}
+ // Set coupling parameters
+ virtual void SetCouplingParam(Double_t col, Double_t row)
+ {fCouplCol = col; fCouplRow = row;}
+ // Get coupling parameters
+ virtual void GetCouplingParam(Double_t &col, Double_t &row) const
+ {col = fCouplCol; row = fCouplRow;}
- //Declaration of member functions peculiar to this class
- // Sets the fraction of Dead SPD Pixels
- void SetFractionDead(Double_t d=0.01){ fDeadPixels = d;}
- // Retruns the fraction of Dead SPD Pixels
- Double_t GetFractionDead() const {return fDeadPixels;}
- // Returns a logical if a pixels is dead or not
- Bool_t IsPixelDead(Int_t mod,Int_t ix,Int_t iz) const ;
virtual void GiveCompressParam(Int_t *) const
{NotImplemented("GiveCompressParam");}
{NotImplemented("SetSigmaSpread");}
virtual void SigmaSpread(Double_t & /* p1 */,Double_t & /* p2 */) const
{NotImplemented("SigmaSpread");}
-
- void SetNBadChannels(Int_t n) {fBadChannels.Set(n);}
- void AddBadChannel(Int_t bad,Int_t i) {fBadChannels.AddAt(bad,i);}
- TArrayI GetBadChannels() const {return fBadChannels;}
- virtual void SetCouplingParam(Double_t col, Double_t row) {((AliITSresponseSPD*)fResponse)->SetCouplingParam(col,row);}
- virtual void GetCouplingParam(Double_t &col, Double_t &row) const {((AliITSresponseSPD*)fResponse)->GetCouplingParam(col, row);}
+
+ virtual void GetCouplingOption(char *opt) const {((AliITSresponseSPD*)fResponse)->CouplingOption(opt);}
+ virtual void SetCouplingOption(const char* opt) {((AliITSresponseSPD*)fResponse)->SetCouplingOption(opt);}
virtual void SetParamOptions(const char* a,const char* b) {((AliITSresponseSPD*)fResponse)->SetParamOptions(a,b);}
virtual void GetParamOptions(char *a,char* b) const {((AliITSresponseSPD*)fResponse)->ParamOptions(a,b);}
+ virtual void SetSigmaDiffusionAsymmetry(Double_t ecc) {((AliITSresponseSPD*)fResponse)->SetSigmaDiffusionAsymmetry(ecc);}
+ virtual void GetSigmaDiffusionAsymmetry(Double_t &ecc) const {((AliITSresponseSPD*)fResponse)->GetSigmaDiffusionAsymmetry(ecc);}
+
+ void AddDead(UInt_t col, UInt_t row);
+ Int_t GetNrDead() {return nrDead;}
+ Int_t GetDeadColAt(UInt_t index); //returns -1 if out of bounds
+ Int_t GetDeadRowAt(UInt_t index); //returns -1 if out of bounds
+ void ClearDead() {fDeadChannels.Reset(); nrDead=0;}
+ Bool_t IsPixelDead(Int_t col, Int_t row) const ;
+ Bool_t IsPixelDead(Int_t mod,Int_t ix,Int_t iz) const ; // remove as soon as possible!!!
+
+ void AddNoisy(UInt_t col, UInt_t row);
+ Int_t GetNrNoisy() {return nrNoisy;}
+ Int_t GetNoisyColAt(UInt_t index); //returns -1 if out of bounds
+ Int_t GetNoisyRowAt(UInt_t index); //returns -1 if out of bounds
+ void ClearNoisy() {fNoisyChannels.Reset(); nrNoisy=0;}
+ Bool_t IsPixelNoisy(Int_t col, Int_t row) const ;
+
protected:
// static const Double_t fgkDiffCoeffDefault; //default for fDiffCoeff
static const Double_t fgkThreshDefault; //default for fThresh
static const Double_t fgkSigmaDefault; //default for fSigma
+ static const Double_t fgkCouplColDefault; //default for fCouplCol
+ static const Double_t fgkCouplRowDefault; //default for fCouplRow
+ static const Double_t fgkBiasVoltageDefault; //default for fBiasVoltage
Double_t fBaseline; // Base-line value
Double_t fNoise; // Gaussian noise scale
Double_t fThresh; // Threshold value
Double_t fSigma; // Noise + threshold fluctuations value
- Double_t fDeadPixels; // the fraction of dead pixels
- TArrayI fBadChannels; // Array with bad channels info (N, row0,col0,row1,col1...rowN,colN)
+ Double_t fCouplCol; // Coupling parameter along the cols
+ Double_t fCouplRow; // Coupling parameter along the rows
+ Double_t fBiasVoltage; // Bias Voltage for the SPD (used to compute DistanceOverVoltage)
+ UInt_t nrDead; // Nr of dead pixels
+ TArrayI fDeadChannels; // Array with dead channels info (col0,row0,col1...rowN) N = nrDead
+ UInt_t nrNoisy; // Nr of noisy pixels
+ TArrayI fNoisyChannels; // Array with noisy channels info (col0,row0,col1...rowN) N = nrNoisy
- ClassDef(AliITSCalibrationSPD,2) // SPD response
+ ClassDef(AliITSCalibrationSPD,3) // SPD response
};
#endif
#include "AliITSDetTypeRec.h"
#include "AliRawReader.h"
#include "AliITSRawStreamSDD.h"
-
+#include "AliITSCalibrationSDD.h"
+#include "AliITSDetTypeRec.h"
+#include "AliITSsegmentationSDD.h"
#include <TClonesArray.h>
#include "AliITSdigitSDD.h"
z= -z+fZshift[fModule];
// c.SetY(y);
// c.SetZ(z);
+ CorrectPosition(z,y);
c.SetYZ(fModule,y,z);
c.SetNy(maxj-minj+1);
c.SetNz(maxi-mini+1);
}
+//_________________________________________________________________________
+void AliITSClusterFinderV2SDD::CorrectPosition(Float_t &z, Float_t&y){
+
+ //correction of coordinates using the maps stored in the DB
+
+ AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule);
+ static const Int_t nbint = cal->GetMapTimeNBin();
+ static const Int_t nbina = cal->Chips()*cal->Channels();
+ Float_t stepa = (GetSeg()->Dpz(0))/10000.; //anode pitch in cm
+ Float_t stept = (GetSeg()->Dx()/cal->GetMapTimeNBin()/2.)/10.;
+ Float_t xdet,zdet;
+ fDetTypeRec->GetITSgeom()->TrackingV2ToDetL(fModule,y,z,xdet,zdet);
+
+ Int_t bint = TMath::Abs((Int_t)(xdet/stept));
+ if(xdet>=0) bint+=(Int_t)(nbint/2.);
+ if(bint>nbint) AliError("Wrong bin number!");
+
+ Int_t bina = TMath::Abs((Int_t)(zdet/stepa));
+ if(zdet>=0) bina+=(Int_t)(nbina/2.);
+ if(bina>nbina) AliError("Wrong bin number!");
+
+ Float_t devz = cal->GetMapACell(bina,bint)/10000.;
+ Float_t devx = cal->GetMapTCell(bina,bint)/10000.;
+ zdet+=devz;
+ xdet+=devx;
+ fDetTypeRec->GetITSgeom()->DetLToTrackingV2(fModule,xdet,zdet,y,z);
+
+
+}
// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
//--------------------------------------------------------------
#include "AliITSClusterFinderV2.h"
+#include "AliITSDetTypeRec.h"
class TClonesArray;
class AliRawReader;
class AliITSRawStream;
+class AliITSCalibrationSDD;
+class AliITSsegmentationSDD;
class AliITSClusterFinderV2SDD : public AliITSClusterFinderV2 {
public:
TClonesArray *dig, TClonesArray *clusters=0x0);
void FindClustersSDD(AliITSRawStream* input,TClonesArray** clusters);
+ void CorrectPosition(Float_t &z, Float_t&y);
+ virtual AliITSCalibrationSDD* GetResp(Int_t mod)const{
+ return (AliITSCalibrationSDD*) fDetTypeRec->GetCalibrationModel(mod);}
+ virtual AliITSsegmentationSDD* GetSeg()const{
+ return (AliITSsegmentationSDD*)fDetTypeRec->GetSegmentationModel(1);}
+
Int_t fNySDD; //number of "pixels" in Y
Int_t fNzSDD; //number of "pixels" in Z
/*
$Log$
+Revision 1.2 2006/02/03 11:31:18 masera
+Calibration framework improved (E. Crescio)
+
Revision 1.1 2005/10/11 12:31:50 masera
Preprocessor classes for SPD (Paul Nilsson)
// .readNoisyChannels.C (Read noisy channels from the CDB)
// .findDeadChannels.C (Locate and store dead channels in the CDB)
// .readDeadChannels.C (Read dead channels from the CDB)
+//
+// Modified by D. Elia, H. Tydesjo
+// March 2006: Mixed up coordinates, bug fixed
+//
///////////////////////////////////////////////////////////////////////////
#include "TFile.h"
{
// Get the current digit
digitSPD = (AliITSdigitSPD*) digitsArraySPD->At(digit);
- row = digitSPD->GetCoord1();
- column = digitSPD->GetCoord2();
+ column = digitSPD->GetCoord1();
+ row = digitSPD->GetCoord2();
// Fill the digits histogram
((TH2F*)(*fDigitsHistogram)[module])->Fill(column, row);
{
// Get the current digit
digitSPD = (AliITSdigitSPD*) digitsArraySPD->At(digit);
- newDigit[0] = digitSPD->GetCoord1(); // row
- newDigit[1] = digitSPD->GetCoord2(); // column
+ newDigit[0] = digitSPD->GetCoord1(); // column
+ newDigit[1] = digitSPD->GetCoord2(); // row
newDigit[2] = digitSPD->GetSignal(); // signal
// Check if this channel is noisy
return kFALSE;
}
+
Int_t i=0;
AliITSChannelSPD *channel = 0;
AliITSCalibrationSPD* res;
for (Int_t module=0; module<respSPD->GetEntries(); module++) {
- Int_t k=0;
res = (AliITSCalibrationSPD*) respSPD->At(module);
- res->SetNBadChannels(fNumberOfBadChannels[module]*2+1);
- res->AddBadChannel(fNumberOfBadChannels[module],k++);
Int_t j = 0;
- while (j < fNumberOfBadChannels[module])
- {
- channel = (AliITSChannelSPD *) fBadChannelsObjArray->At(i++);
- res->AddBadChannel(channel->GetColumn(),k++);
- res->AddBadChannel(channel->GetRow(),k++);
-
- // Go to next bad channel
- j++;
- }
-
-
+ while (j < fNumberOfBadChannels[module]) {
+ channel = (AliITSChannelSPD *) fBadChannelsObjArray->At(i++);
+ res->AddDead(channel->GetColumn(),channel->GetRow());
+ // Go to next bad channel
+ j++;
+ }
}
+
AliCDBManager::Instance()->Put(entrySPD);
entrySPD->SetObject(NULL);
* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
-//////////////////////////////////////////////////////
-// Base Response class forITS //
-// It is used to set static data members //
-// connected to parameters equal for all //
-// the SPD modules //
-//////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+// Base Response class forITS
+// It is used to set static data members
+// connected to parameters equal for all
+// the SPD modules
+//
+// Modified by D. Elia, G.E. Bruno
+// March-April 2006
+//
+///////////////////////////////////////////////////////////////////////////
+
#include "AliITSresponseSPD.h"
-const Float_t AliITSresponseSPD::fgkDiffCoeffDefault = 0.;
+const Float_t AliITSresponseSPD::fgkDiffCoeffDefault = 0.; //change this
+const TString AliITSresponseSPD::fgkCouplingOptDefault = "old";
const Float_t AliITSresponseSPD::fgkCouplingColDefault = 0;
-const Float_t AliITSresponseSPD::fgkCouplingRowDefault = 0;
+const Float_t AliITSresponseSPD::fgkCouplingRowDefault = 0.047;
+const Float_t AliITSresponseSPD::fgkEccentricityDiffDefault = 0.85;
+//geb const Float_t AliITSresponseSPD::fgkDistanceOverVoltage = 0.0010;
ClassImp(AliITSresponseSPD)
//______________________________________________________________________
// constructor
SetCouplingParam(fgkCouplingColDefault,fgkCouplingRowDefault);
+ SetCouplingOption(fgkCouplingOptDefault);
SetDiffCoeff(fgkDiffCoeffDefault,0.);
+ SetSigmaDiffusionAsymmetry(fgkEccentricityDiffDefault);
}
{fCouplCol=col; fCouplRow=row;}
virtual void GetCouplingParam(Double_t &col, Double_t &row) const
{col=fCouplCol; row=fCouplRow;}
+ virtual void SetCouplingOption(const char *opt) { // Options: "old" or "new"
+ fCouplOpt=opt;}
+ virtual void CouplingOption(char *opt) const {
+ strcpy(opt,fCouplOpt.Data());}
+ virtual void SetSigmaDiffusionAsymmetry(Double_t ecc)
+ {fEccDiff=ecc;}
+ virtual void GetSigmaDiffusionAsymmetry(Double_t &ecc) const
+ {ecc=fEccDiff;}
virtual void SetParamOptions(const char* /* a */,const char* /* b */)
{NotImplemented("SetParamOptions");}
virtual void ParamOptions(char *,char*) const
protected:
static const Float_t fgkDiffCoeffDefault; //default for fDiffCoeff
+ static const TString fgkCouplingOptDefault; // type of pixel Coupling (old or new)
static const Float_t fgkCouplingColDefault;//default for fCouplCol
static const Float_t fgkCouplingRowDefault;//default for fCouplRow
+ static const Float_t fgkEccentricityDiffDefault;//default for fCouplRow
Float_t fCouplCol; // Coupling probability along a column
Float_t fCouplRow; // Coupling probability along a row
+ TString fCouplOpt; // Coupling Option
+ Float_t fEccDiff; // Eccentricity (i.e. asymmetry parameter) in the Gaussian Diffusion
- ClassDef(AliITSresponseSPD,4) // SPD base response class
+ ClassDef(AliITSresponseSPD,5) // SPD base response class
};
#endif
* provided "as is" without express or implied warranty. *
**************************************************************************/
-/* $Id$ */
+/*
+$Id$
+*/
-#include <TRandom.h>
+#include <Riostream.h>
#include <TH1.h>
+#include <TMath.h>
+#include <TParticle.h>
+#include <TRandom.h>
#include <TString.h>
-
-#include "AliRun.h"
#include "AliITS.h"
+#include "AliITSMapA2.h"
#include "AliITSdigitSPD.h"
+#include "AliITSgeom.h"
+#include "AliITShit.h"
#include "AliITSmodule.h"
-#include "AliITSMapA2.h"
#include "AliITSpList.h"
+#include "AliITSCalibrationSPD.h"
+#include "AliITSsegmentationSPD.h"
#include "AliITSsimulationSPD.h"
#include "AliLog.h"
+#include "AliRun.h"
//#define DEBUG
ClassImp(AliITSsimulationSPD)
////////////////////////////////////////////////////////////////////////
-// Version: 0
-// Written by Rocco Caliandro
-// from a model developed with T. Virgili and R.A. Fini
-// June 15 2000
+// Version: 1
+// Modified by Bjorn S. Nilsen, G.E. Bruno, H. Tydesjo
+// March-April 2006
//
-// AliITSsimulationSPD is the simulation of SPDs
+// Version: 0
+// Written by Boris Batyunya
+// December 20 1999
//
+//
+// AliITSsimulationSPD is to do the simulation of SPDs.
+//
+////////////////////////////////////////////////////////////////////////
+
//______________________________________________________________________
-AliITSsimulationSPD::AliITSsimulationSPD() : AliITSsimulation(),
-fMapA2(0),
-fHis(0){
- // Default constructor
- // Inputs:
+AliITSsimulationSPD::AliITSsimulationSPD():
+AliITSsimulation(),
+fHis(0),
+fSPDname(),
+fCoupling(){
+ // Default constructor.
+ // Inputs:
// none.
// Outputs:
// none.
// Return:
// A default constructed AliITSsimulationSPD class.
+
+ AliDebug(1,Form("Calling default constructor"));
+// Init();
}
//______________________________________________________________________
AliITSsimulationSPD::AliITSsimulationSPD(AliITSDetTypeSim *dettyp):
AliITSsimulation(dettyp),
-fMapA2(0),
-fHis(0){
- // Standard constructor
- // Inputs:
- // AliITSsegmentation *seg Segmentation class to be used
- // AliITSresonse *res Response class to be used
+fHis(0),
+fSPDname(),
+fCoupling(){
+ // standard constructor
+ // Inputs:
+ // AliITSsegmentation *seg A pointer to the segmentation class
+ // to be used for this simulation
+ // AliITSCalibration *resp A pointer to the responce class to
+ // be used for this simulation
// Outputs:
// none.
// Return:
- // A standard constructed AliITSsimulationSPD class.
+ // A default constructed AliITSsimulationSPD class.
+ AliDebug(1,Form("Calling standard constructor "));
+// AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
+// res->SetTemperature(0.0);
+// res->SetDistanceOverVoltage(0.0);
Init();
}
//______________________________________________________________________
-void AliITSsimulationSPD::Init() {
- // Initilizes the variables of AliITSsimulation SPD.
+void AliITSsimulationSPD::Init(){
+ // Initilization
// Inputs:
// none.
// Outputs:
// none.
// Return:
// none.
+ const Double_t kmictocm = 1.0e-4; // convert microns to cm.
- fHis = 0;
- if(fMapA2) delete fMapA2;
+ SetModuleNumber(0);
+ SetEventNumber(0);
+ SetMap(new AliITSpList(GetNPixelsZ(),GetNPixelsX()));
+ AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
- fMapA2 = new AliITSMapA2(seg);
- if(fpList) delete fpList;
- fpList = new AliITSpList(GetNPixelsZ()+1,GetNPixelsX()+1);
-}
-/*
-//______________________________________________________________________
-void AliITSsimulationSPD::Init(AliITSsegmentationSPD *seg,
- AliITSCalibrationSPD *resp) {
- // Initilizes the variables of AliITSsimulation SPD.
- // Inputs:
- // AliITSsegmentationSPD replacement segmentation class to be used
- // aliITSresponseSPD replacement response class to be used
- // Outputs:
- // none.
- // Return:
- // none.
+ Double_t bias = res->GetBiasVoltage();
+// cout << "Bias Voltage --> " << bias << endl; // dom
+ res->SetDistanceOverVoltage(kmictocm*seg->Dy(),bias);
+// set kind of coupling ("old" or "new")
+ char opt[20];
+ res->GetCouplingOption(opt);
+ char *old = strstr(opt,"old");
+ if (old) {
+ fCoupling=2;
+ } else {
+ fCoupling=1;
+ } // end if
+
+ // Get the calibration objects for each module(ladder)
+ GetCalibrationObjects(0); //RunNr 0 hard coded for now
- if(fHis){
- fHis->Delete();
- delete fHis;
- } // end if fHis
- fHis = 0;
- if(fResponse) delete fResponse;
- fResponse = resp;
- if(GetSegmentationModel(0)) delete GetSegmentationModel(0);
- GetSegmentationModel(0) = seg;
- if(fMapA2) delete fMapA2;
- fMapA2 = new AliITSMapA2(GetSegmentationModel(0));
- if(fpList) delete fpList;
- fpList = new AliITSpList(GetNPixelsZ()+1,GetNPixelsX()+1);
}
-*/
//______________________________________________________________________
-AliITSsimulationSPD::~AliITSsimulationSPD() {
+AliITSsimulationSPD::~AliITSsimulationSPD(){
// destructor
- // Inputs:
+ // Inputs:
// none.
// Outputs:
// none.
// Return:
- // none.
+ // none.
- if(fMapA2) delete fMapA2;
if (fHis) {
fHis->Delete();
delete fHis;
- } // end if
+ } // end if fHis
}
//______________________________________________________________________
-AliITSsimulationSPD::AliITSsimulationSPD(const AliITSsimulationSPD &source) :
- AliITSsimulation(source){
- // Copy Constructor
- // Inputs:
- // none.
+AliITSsimulationSPD::AliITSsimulationSPD(const
+ AliITSsimulationSPD
+ &s) : AliITSsimulation(s){
+ // Copy Constructor
+ // Inputs:
+ // AliITSsimulationSPD &s The original class for which
+ // this class is a copy of
// Outputs:
// none.
// Return:
- // A new AliITSsimulationSPD class with the same parameters as source.
-
- if(&source == this) return;
- this->fMapA2 = source.fMapA2;
- this->fHis = source.fHis;
+ *this = s;
return;
}
//______________________________________________________________________
-AliITSsimulationSPD& AliITSsimulationSPD::operator=(const AliITSsimulationSPD
- &source) {
+AliITSsimulationSPD& AliITSsimulationSPD::operator=(const
+ AliITSsimulationSPD &s){
// Assignment operator
- // Inputs:
- // none.
+ // Inputs:
+ // AliITSsimulationSPD &s The original class for which
+ // this class is a copy of
// Outputs:
// none.
// Return:
- // A new AliITSsimulationSPD class with the same parameters as source.
-
- if(&source == this) return *this;
- this->fMapA2 = source.fMapA2;
- this->fHis = source.fHis;
+ if(&s == this) return *this;
+ this->fHis = s.fHis;
+ fCoupling = s.fCoupling;
+ fSPDname = s.fSPDname;
return *this;
-}
+}
//______________________________________________________________________
-AliITSsimulation& AliITSsimulationSPD::operator=(const AliITSsimulation
- &source) {
+AliITSsimulation& AliITSsimulationSPD::operator=(const
+ AliITSsimulation &s){
// Assignment operator
- // Inputs:
- // none.
+ // Inputs:
+ // AliITSsimulationSPD &s The original class for which
+ // this class is a copy of
// Outputs:
// none.
// Return:
- // A new AliITSsimulationSPD class with the same parameters as source.
- if(&source == this) return *this;
+ if(&s == this) return *this;
Error("AliITSsimulationSPD","Not allowed to make a = with "
- "AliITSsimulationSPD Using default creater instead");
+ "AliITSsimulationSPD","Using default creater instead");
return *this;
-}
+}
//______________________________________________________________________
-void AliITSsimulationSPD::InitSimulationModule(Int_t module,Int_t event){
- // Creates maps to build the list of tracks for each sumable digit
- // Inputs:
- // Int_t module // Module number to be simulated
- // Int_t event // Event number to be simulated
- // Outputs:
- // none.
- // Return
+void AliITSsimulationSPD::GetCalibrationObjects(Int_t RunNr) {
+ AliCDBManager* man = AliCDBManager::Instance();
+ if(!man->IsDefaultStorageSet()) {
+ man->SetDefaultStorage("local://$ALICE_ROOT");
+ }
+ AliCDBEntry *entrySPD = man->Get("ITS/Calib/CalibSPD", RunNr);
+ if(!entrySPD){
+ AliWarning("Cannot find SPD calibration entry!");
+ return;
+ }
+ TObjArray *respSPD = (TObjArray *)entrySPD->GetObject();
+ if ((! respSPD)) {
+ AliWarning("Cannot get data from SPD database entry!");
+ return;
+ }
+ for (Int_t mod=0; mod<240; mod++) {
+ calObj[mod] = (AliITSCalibrationSPD*) respSPD->At(mod);
+ }
+}
+
+//______________________________________________________________________
+void AliITSsimulationSPD::InitSimulationModule(Int_t module, Int_t event){
+ // This function creates maps to build the list of tracks for each
+ // summable digit. Inputs defined by base class.
+ // Inputs:
+ // Int_t module // Module number to be simulated
+ // Int_t event // Event number to be simulated
+ // Outputs:
+ // none
+ // Returns:
+ // none
+
+ AliDebug(1,Form("(module=%d,event=%d)",module,event));
+ SetModuleNumber(module);
+ SetEventNumber(event);
+ ClearMap();
+}
+//_____________________________________________________________________
+void AliITSsimulationSPD::SDigitiseModule(AliITSmodule *mod,Int_t,
+ Int_t event){
+ // This function begins the work of creating S-Digits. Inputs defined
+ // by base class.
+ // Inputs:
+ // AliITSmodule *mod // module
+ // Int_t // not used
+ // Int_t event // Event number
+ // Outputs:
+ // none
+ // Return:
+ // test // test returns kTRUE if the module contained hits
+ // // test returns kFALSE if it did not contain hits
+
+ AliDebug(1,Form("(mod=%p, ,event=%d)",mod,event));
+ if(!(mod->GetNhits())){
+ AliDebug(1,Form("In event %d module %d there are %d hits returning.",
+ event, mod->GetIndex(),mod->GetNhits()));
+ return;// if module has no hits don't create Sdigits
+ } // end if
+ SetModuleNumber(mod->GetIndex());
+ SetEventNumber(event);
+ // HitToSDigit(mod);
+ HitToSDigitFast(mod);
+ WriteSDigits();
+ ClearMap();
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::WriteSDigits(){
+ // This function adds each S-Digit to pList
+ // Inputs:
// none.
-
- fModule = module;
- fEvent = event;
- fMapA2->ClearMap();
- fpList->ClearMap();
+ // Outputs:
+ // none.
+ // Return:
+ // none
+ Int_t ix, nix, iz, niz;
+ static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
+
+ AliDebug(1,Form("Writing SDigits for module %d",GetModuleNumber()));
+ GetMap()->GetMaxMapIndex(niz, nix);
+ for(iz=0; iz<niz; iz++)for(ix=0; ix<nix; ix++){
+ if(GetMap()->GetSignalOnly(iz,ix)>0.0){
+ aliITS->AddSumDigit(*(GetMap()->GetpListItem(iz,ix)));
+ if(AliDebugLevel()>0) {
+ AliDebug(1,Form("%d, %d",iz,ix));
+ cout << *(GetMap()->GetpListItem(iz,ix)) << endl;
+ } // end if GetDebug
+ } // end if GetMap()->GetSignalOnly(iz,ix)>0.0
+ } // end for iz,ix
+ return;
}
//______________________________________________________________________
void AliITSsimulationSPD::FinishSDigitiseModule(){
- // Does the Sdigits to Digits work
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
+ // This function calls SDigitsToDigits which creates Digits from SDigits
+ // Inputs:
+ // none
+ // Outputs:
+ // none
+ // Return
+ // none
+
+ AliDebug(1,"()");
+ pListToDigits(); // Charge To Signal both adds noise and
+ ClearMap();
+ return;
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::DigitiseModule(AliITSmodule *mod,Int_t,
+ Int_t){
+ // This function creates Digits straight from the hits and then adds
+ // electronic noise to the digits before adding them to pList
+ // Each of the input variables is passed along to HitToSDigit
+ // Inputs:
+ // AliITSmodule *mod module
+ // Int_t Dummy.
+ // Int_t Dummy
+ // Outputs:
+ // none.
+ // Return:
+ // none.
- SDigitsToDigits(fModule,fpList);
+ AliDebug(1,Form("(mod=%p,,)",mod));
+ // HitToSDigit(mod);
+ HitToSDigitFast(mod);
+ RemoveDeadPixels(mod);
+ pListToDigits();
+ ClearMap();
}
//______________________________________________________________________
-void AliITSsimulationSPD::SDigitiseModule(AliITSmodule *mod, Int_t dummy0,
- Int_t dummy1) {
- // Sum digitize module
+void AliITSsimulationSPD::HitToSDigit(AliITSmodule *mod){
+ // Does the charge distributions using Gaussian diffusion charge charing.
// Inputs:
- // AliITSmodule *mod The module to be SDgitized
- // Int_t dummy0 Not used kept for general compatibility
- // Int_t dummy1 Not used kept for general compatibility
- // Outputs:
- // none.
+ // AliITSmodule *mod Pointer to this module
+ // Output:
+ // none.
// Return:
- // none.
- if (!(mod->GetNhits())) return; // if module has no hits then no Sdigits.
- Int_t number = 10000;
- Int_t *frowpixel = new Int_t[number];
- Int_t *fcolpixel = new Int_t[number];
- Double_t *fenepixel = new Double_t[number];
-
- dummy0 = dummy1; // remove unsued variable warning.
- fModule = mod->GetIndex();
-
- // Array of pointers to store the track index of the digits
- // leave +1, otherwise pList crashes when col=256, row=192
-
- HitsToAnalogDigits(mod,frowpixel,fcolpixel,fenepixel,fpList);
-
- WriteSDigits(fpList);
-
- // clean memory
- delete[] frowpixel;
- delete[] fcolpixel;
- delete[] fenepixel;
- fMapA2->ClearMap();
- fpList->ClearMap();
+ // none.
+ const Double_t kmictocm = 1.0e-4; // convert microns to cm.
+ TObjArray *hits = mod->GetHits();
+ Int_t nhits = hits->GetEntriesFast();
+ Int_t h,ix,iz,i;
+ Int_t idtrack;
+ Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0;
+ Double_t x,y,z,t,tp,st,dt=0.2,el,sig,sigx,sigz,fda;
+ AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
+ AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
+ Double_t thick = 0.5*kmictocm*seg->Dy(); // Half Thickness
+ res->GetSigmaDiffusionAsymmetry(fda);
+
+ AliDebug(1,Form("(mod=%p) fCoupling=%d",mod,fCoupling));
+ if(nhits<=0) return;
+ for(h=0;h<nhits;h++){
+ if(AliDebugLevel()>0) {
+ AliDebug(1,Form("Hits, %d", h));
+ cout << *(mod->GetHit(h)) << endl;
+ } // end if GetDebug
+ if(!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue;
+ st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
+ if(st>0.0){
+ st = (Double_t)((Int_t)(st/kmictocm)); // number of microns
+ if(st<=1.0) st = 1.0;
+ dt = 1.0/st;
+ for(t=0.0;t<1.0;t+=dt){ // Integrate over t
+ tp = t+0.5*dt;
+ x = x0+x1*tp;
+ y = y0+y1*tp;
+ z = z0+z1*tp;
+ if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
+ el = res->GeVToCharge((Double_t)(dt*de));
+ if(GetDebug(1)){
+ if(el<=0.0) cout<<"el="<<el<<" dt="<<dt
+ <<" de="<<de<<endl;
+ } // end if GetDebug
+ sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
+ // SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
+ sigx=sig;
+ sigz=sig*fda;
+ SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
+ cout << "sigx, sigz, y "<< sigx << " " << sigz<< " " << TMath::Abs(thick + y) << endl;// ciccio
+ } // end for t
+ } else { // st == 0.0 deposit it at this point
+ x = x0;
+ y = y0;
+ z = z0;
+ if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
+ el = res->GeVToCharge((Double_t)de);
+ sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
+ // SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
+ sigx=sig;
+ sigz=sig*fda;
+ SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
+ } // end if st>0.0
+ // Coupling
+ switch (fCoupling) {
+ default:
+ break;
+ case 1: //case 3:
+ // x is column and z is row (see AliITSsegmentationSPD::GetPadIxz)
+ for(i=0;i<GetMap()->GetEntries();i++)
+ if(GetMap()->GetpListItem(i)==0) continue;
+ else{
+ GetMap()->GetMapIndex(
+ GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
+ SetCoupling(iz,ix,idtrack,h);
+ } // end for i
+ break;
+ case 2: // case 4:
+ // x is column and z is row (see AliITSsegmentationSPD::GetPadIxz)
+ for(i=0;i<GetMap()->GetEntries();i++)
+ if(GetMap()->GetpListItem(i)==0) continue;
+ else{
+ GetMap()->GetMapIndex(
+ GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
+ SetCouplingOld(iz,ix,idtrack,h);
+ } // end for i
+ break;
+ } // end switch
+ } // Loop over all hits h
+ if(GetDebug(2))Info("HitToSDigit","Finished fCoupling=%d",fCoupling);
}
//______________________________________________________________________
-void AliITSsimulationSPD::DigitiseModule(AliITSmodule *mod, Int_t,Int_t) {
- // digitize module. Also need to digitize modules with only noise.
- // Inputs:
- // AliITSmodule *mod The module to be SDgitized
- // Outputs:
- // none.
+void AliITSsimulationSPD::HitToSDigitFast(AliITSmodule *mod){
+ // Does the charge distributions using Gaussian diffusion charge charing. // Inputs:
+ // AliITSmodule *mod Pointer to this module
+ // Output:
+ // none.
// Return:
- // none.
-
- Int_t number = 10000;
- Int_t *frowpixel = new Int_t[number];
- Int_t *fcolpixel = new Int_t[number];
- Double_t *fenepixel = new Double_t[number];
-
- // Array of pointers to store the track index of the digits
- // leave +1, otherwise pList crashes when col=256, row=192
- fModule = mod->GetIndex();
- // noise setting
- SetFluctuations(fpList,fModule);
-
- HitsToAnalogDigits(mod,frowpixel,fcolpixel,fenepixel,fpList);
-
- // apply mask to SPD module
- SetMask(fModule);
-
- CreateDigit(fModule,fpList);
-
- // clean memory
- delete[] frowpixel;
- delete[] fcolpixel;
- delete[] fenepixel;
- fMapA2->ClearMap();
- fpList->ClearMap();
+ // none.
+ const Double_t kmictocm = 1.0e-4; // convert microns to cm.
+ const Int_t n10=10;
+ const Double_t ti[n10]={7.443716945e-3,2.166976971e-1,3.397047841e-1,
+ 4.325316833e-1,4.869532643e-1,5.130467358e-1,
+ 5.674683167e-1,6.602952159e-1,7.833023029e-1,
+ 9.255628306e-1};
+ const Double_t wi[n10]={1.477621124e-1,1.346333597e-1,1.095431813e-1,
+ 7.472567455e-2,3.333567215e-2,3.333567215e-2,
+ 7.472567455e-2,1.095431813e-1,1.346333597e-1,
+ 1.477621124e-1};
+ TObjArray *hits = mod->GetHits();
+ Int_t nhits = hits->GetEntriesFast();
+ Int_t h,ix,iz,i;
+ Int_t idtrack;
+ Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0;
+ Double_t x,y,z,t,st,el,sig,sigx,sigz,fda;
+ AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
+ AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
+ Double_t thick = 0.5*kmictocm*seg->Dy(); // Half thickness
+ res->GetSigmaDiffusionAsymmetry(fda);
+// cout << "Half Thickness " << thick << endl; // dom
+// cout << "Diffusion asymm " << fda << endl; // dom
+
+ AliDebug(1,Form("(mod=%p) fCoupling=%d",mod,fCoupling));
+ if(nhits<=0) return;
+ for(h=0;h<nhits;h++){
+ if(AliDebugLevel()>0) {
+ AliDebug(1,Form("Hits, %d", h));
+ cout << *(mod->GetHit(h)) << endl;
+ } // end if GetDebug
+ if(!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue;
+ st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
+ if(st>0.0) for(i=0;i<n10;i++){ // Integrate over t
+ t = ti[i];
+ x = x0+x1*t;
+ y = y0+y1*t;
+ z = z0+z1*t;
+ if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
+ // el = res->GeVToCharge((Double_t)(dt*de));
+ // el = 1./n10*res->GeVToCharge((Double_t)de);
+ el = wi[i]*res->GeVToCharge((Double_t)de);
+ if(GetDebug(1)){
+ if(el<=0.0) cout<<"el="<<el<<" wi["<<i<<"]="<<wi[i]
+ <<" de="<<de<<endl;
+ } // end if GetDebug
+ sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
+ sigx=sig;
+ sigz=sig*fda;
+ //SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
+ SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
+ // cout << "sigx sigz " << sigx << " " << sigz << endl; // dom
+ } // end for i // End Integrate over t
+ else { // st == 0.0 deposit it at this point
+ x = x0;
+ y = y0;
+ z = z0;
+ if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
+ el = res->GeVToCharge((Double_t)de);
+ sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
+ //SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
+ sigx=sig;
+ sigz=sig*fda;
+ SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
+ } // end if st>0.0
+ // Coupling
+ switch (fCoupling) {
+ default:
+ break;
+ case 1: // case 3:
+ // x is column and z is row (see AliITSsegmentationSPD::GetPadIxz)
+ for(i=0;i<GetMap()->GetEntries();i++)
+ if(GetMap()->GetpListItem(i)==0) continue;
+ else{
+ GetMap()->GetMapIndex(
+ GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
+ SetCoupling(iz,ix,idtrack,h);
+ } // end for i
+ break;
+ case 2: // case 4:
+ // x is column and z is row (see AliITSsegmentationSPD::GetPadIxz)
+ for(i=0;i<GetMap()->GetEntries();i++)
+ if(GetMap()->GetpListItem(i)==0) continue;
+ else{
+ GetMap()->GetMapIndex(
+ GetMap()->GetpListItem(i)->GetIndex(),iz,ix); SetCouplingOld(iz,ix,idtrack,h);
+ } // end for i
+ break;
+ } // end switch
+ } // Loop over all hits h
+ if(GetDebug(2))Info("HitToSDigit","Finished fCoupling=%d",fCoupling);
}
//______________________________________________________________________
-void AliITSsimulationSPD::SDigitsToDigits(Int_t module,AliITSpList *pList) {
- // sum digits to Digits.
+void AliITSsimulationSPD::SpreadCharge(Double_t x0,Double_t z0,
+ Int_t ix0,Int_t iz0,
+ Double_t el,Double_t sig,Int_t t,
+ Int_t hi){
+ // Spreads the charge over neighboring cells. Assume charge is distributed
+ // as charge(x,z) = (el/2*pi*sig*sig)*exp(-arg)
+ // arg=((x-x0)*(x-x0)/2*sig*sig)+((z-z0*z-z0)/2*sig*sig)
+ // Defined this way, the integral over all x and z is el.
// Inputs:
- // AliITSmodule *mod The module to be SDgitized
- // AliITSpList *pList the array of SDigits
+ // Double_t x0 x position of point where charge is liberated
+ // Double_t y0 y position of point where charge is liberated
+ // Double_t z0 z position of point where charge is liberated
+ // Int_t ix0 row of cell corresponding to point x0
+ // Int_t iz0 columb of cell corresponding to point z0
+ // Double_t el number of electrons liberated in this step
+ // Double_t sig Sigma difusion for this step (y0 dependent)
+ // Int_t t track number
+ // Int_t ti hit track index number
+ // Int_t hi hit "hit" index number
// Outputs:
- // AliITSpList *pList the array of SDigits
+ // none.
// Return:
- // none.
-
- AliDebug(1,Form("Entering AliITSsimulatinSPD::SDigitsToDigits for module=%d",
- module));
- fModule = module;
-
- // noise setting
- SetFluctuations(pList,module);
-
- fMapA2->ClearMap(); // since noise is in pList aready. Zero Map so that
- // noise is not doubled when calling FillMapFrompList.
-
- FillMapFrompList(pList);
-
- // apply mask to SPD module
- SetMask(fModule);
+ // none.
+ const Int_t knx = 3,knz = 2;
+ const Double_t kRoot2 = 1.414213562; // Sqrt(2).
+ const Double_t kmictocm = 1.0e-4; // convert microns to cm.
+ Int_t ix,iz,ixs,ixe,izs,ize;
+ Float_t x,z;
+ Double_t x1,x2,z1,z2,s,sp;
+ AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
- CreateDigit(module,pList);
- fMapA2->ClearMap();
- pList->ClearMap();
+ if(GetDebug(4)) Info("SpreadCharge","(x0=%e,z0=%e,ix0=%d,iz0=%d,el=%e,"
+ "sig=%e,t=%d,i=%d)",x0,z0,ix0,iz0,el,sig,t,hi);
+ if(sig<=0.0) { // if sig<=0 No diffusion to simulate.
+ GetMap()->AddSignal(iz0,ix0,t,hi,GetModuleNumber(),el);
+ if(GetDebug(2)){
+ cout << "sig<=0.0=" << sig << endl;
+ } // end if GetDebug
+ return;
+ } // end if
+ sp = 1.0/(sig*kRoot2);
+ if(GetDebug(2)){
+ cout << "sig=" << sig << " sp=" << sp << endl;
+ } // end if GetDebug
+ ixs = TMath::Max(-knx+ix0,0);
+ ixe = TMath::Min(knx+ix0,seg->Npx()-1);
+ izs = TMath::Max(-knz+iz0,0);
+ ize = TMath::Min(knz+iz0,seg->Npz()-1);
+ for(ix=ixs;ix<=ixe;ix++) for(iz=izs;iz<=ize;iz++){
+ seg->DetToLocal(ix,iz,x,z); // pixel center
+ x1 = x;
+ z1 = z;
+ x2 = x1 + 0.5*kmictocm*seg->Dpx(ix); // Upper
+ x1 -= 0.5*kmictocm*seg->Dpx(ix); // Lower
+ z2 = z1 + 0.5*kmictocm*seg->Dpz(iz); // Upper
+ z1 -= 0.5*kmictocm*seg->Dpz(iz); // Lower
+ x1 -= x0; // Distance from where track traveled
+ x2 -= x0; // Distance from where track traveled
+ z1 -= z0; // Distance from where track traveled
+ z2 -= z0; // Distance from where track traveled
+ s = 0.25; // Correction based on definision of Erfc
+ s *= TMath::Erfc(sp*x1) - TMath::Erfc(sp*x2);
+ if(GetDebug(3)){
+ cout <<"el="<<el<<" ix0="<<ix0<<" ix="<<ix<<" x0="<<x<<
+ " iz0="<<iz0<<" iz="<<iz<<" z0="<<z<<
+ " sp*x1="<<sp*x1<<" sp*x2="<<sp*x2<<" s="<<s;
+ } // end if GetDebug
+ s *= TMath::Erfc(sp*z1) - TMath::Erfc(sp*z2);
+ if(GetDebug(3)){
+ cout<<" sp*z1="<<sp*z1<<" sp*z2="<<sp*z2<<" s="<<s<< endl;
+ } // end if GetDebug
+ GetMap()->AddSignal(iz,ix,t,hi,GetModuleNumber(),s*el);
+ } // end for ix, iz
}
//______________________________________________________________________
-void AliITSsimulationSPD::UpdateMapSignal(Int_t row,Int_t col,Int_t trk,
- Int_t hit,Int_t mod,Double_t ene,
- AliITSpList *pList) {
- // updates the Map of signal, adding the energy (ene) released by
- // the current track
+void AliITSsimulationSPD::SpreadChargeAsym(Double_t x0,Double_t z0,
+ Int_t ix0,Int_t iz0,
+ Double_t el,Double_t sigx,Double_t sigz,
+ Int_t t,Int_t hi){
+ // Spreads the charge over neighboring cells. Assume charge is distributed
+ // as charge(x,z) = (el/2*pi*sigx*sigz)*exp(-arg)
+ // arg=((x-x0)*(x-x0)/2*sigx*sigx)+((z-z0*z-z0)/2*sigz*sigz)
+ // Defined this way, the integral over all x and z is el.
// Inputs:
- // Int_t row pixel row number
- // Int_t col pixel column number
- // Int_t trk track number which contributed
- // Int_t hit hit number which contributed
- // Int_t mod module number
- // Double_t ene the energy associated with this contribution
- // AliITSpList *pList the array of SDigits
+ // Double_t x0 x position of point where charge is liberated
+ // Double_t y0 y position of point where charge is liberated
+ // Double_t z0 z position of point where charge is liberated
+ // Int_t ix0 row of cell corresponding to point x0
+ // Int_t iz0 columb of cell corresponding to point z0
+ // Double_t el number of electrons liberated in this step
+ // Double_t sigx Sigma difusion along x for this step (y0 dependent)
+ // Double_t sigz Sigma difusion along z for this step (y0 dependent)
+ // Int_t t track number
+ // Int_t ti hit track index number
+ // Int_t hi hit "hit" index number
// Outputs:
- // AliITSpList *pList the array of SDigits
+ // none.
// Return:
- // none.
+ // none.
+ const Int_t knx = 3,knz = 2;
+ const Double_t kRoot2 = 1.414213562; // Sqrt(2).
+ const Double_t kmictocm = 1.0e-4; // convert microns to cm.
+ Int_t ix,iz,ixs,ixe,izs,ize;
+ Float_t x,z;
+ Double_t x1,x2,z1,z2,s,spx,spz;
+ AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
+
- fMapA2->AddSignal(row,col,ene);
- pList->AddSignal(row,col,trk,hit,mod,ene);
+ if(GetDebug(4)) Info("SpreadCharge","(x0=%e,z0=%e,ix0=%d,iz0=%d,el=%e,"
+ "sig=%e,t=%d,i=%d)",x0,z0,ix0,iz0,el,sigx,sigz,t,hi);
+ if(sigx<=0.0 || sigz<=0.0) { // if sig<=0 No diffusion to simulate.
+ GetMap()->AddSignal(iz0,ix0,t,hi,GetModuleNumber(),el);
+ if(GetDebug(2)){
+ cout << "sigx<=0.0=" << sigx << endl;
+ cout << "sigz<=0.0=" << sigz << endl;
+ } // end if GetDebug
+ return;
+ } // end if
+ spx = 1.0/(sigx*kRoot2); spz = 1.0/(sigz*kRoot2);
+ if(GetDebug(2)){
+ cout << "sigx=" << sigx << " spx=" << spx << endl;
+ cout << "sigz=" << sigz << " spz=" << spz << endl;
+ } // end if GetDebug
+ ixs = TMath::Max(-knx+ix0,0);
+ ixe = TMath::Min(knx+ix0,seg->Npx()-1);
+ izs = TMath::Max(-knz+iz0,0);
+ ize = TMath::Min(knz+iz0,seg->Npz()-1);
+ for(ix=ixs;ix<=ixe;ix++) for(iz=izs;iz<=ize;iz++){
+ seg->DetToLocal(ix,iz,x,z); // pixel center
+ x1 = x;
+ z1 = z;
+ x2 = x1 + 0.5*kmictocm*seg->Dpx(ix); // Upper
+ x1 -= 0.5*kmictocm*seg->Dpx(ix); // Lower
+ z2 = z1 + 0.5*kmictocm*seg->Dpz(iz); // Upper
+ z1 -= 0.5*kmictocm*seg->Dpz(iz); // Lower
+ x1 -= x0; // Distance from where track traveled
+ x2 -= x0; // Distance from where track traveled
+ z1 -= z0; // Distance from where track traveled
+ z2 -= z0; // Distance from where track traveled
+ s = 0.25; // Correction based on definision of Erfc
+ s *= TMath::Erfc(spx*x1) - TMath::Erfc(spx*x2);
+ if(GetDebug(3)){
+ cout <<"el="<<el<<" ix0="<<ix0<<" ix="<<ix<<" x0="<<x<<
+ " iz0="<<iz0<<" iz="<<iz<<" z0="<<z<<
+ " spx*x1="<<spx*x1<<" spx*x2="<<spx*x2<<" s="<<s;
+ } // end if GetDebug
+ s *= TMath::Erfc(spz*z1) - TMath::Erfc(spz*z2);
+ if(GetDebug(3)){
+ cout<<" spz*z1="<<spz*z1<<" spz*z2="<<spz*z2<<" s="<<s<< endl;
+ } // end if GetDebug
+ GetMap()->AddSignal(iz,ix,t,hi,GetModuleNumber(),s*el);
+ } // end for ix, iz
}
//______________________________________________________________________
-void AliITSsimulationSPD::UpdateMapNoise(Int_t row,Int_t col,Int_t mod,
- Double_t ene,AliITSpList *pList) {
- // updates the Map of noise, adding the energy (ene) give my noise
+void AliITSsimulationSPD::RemoveDeadPixels(AliITSmodule *mod){
+ Int_t module_nr = mod->GetIndex();
+ Int_t nr_dead = calObj[module_nr]->GetNrDead();
+ for (Int_t i=0; i<nr_dead; i++) {
+ GetMap()->DeleteHit(calObj[module_nr]->GetDeadColAt(i),calObj[module_nr]->GetDeadRowAt(i));
+ }
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::pListToDigits(){
+ // add noise and electronics, perform the zero suppression and add the
+ // digit to the list
// Inputs:
- // Int_t row pixel row number
- // Int_t col pixel column number
- // Int_t mod module number
- // Double_t ene the energy associated with this contribution
- // AliITSpList *pList the array of SDigits
+ // none.
// Outputs:
- // AliITSpList *pList the array of SDigits
+ // none.
// Return:
- // none.
-
- fMapA2->AddSignal(row,col,ene);
- pList->AddNoise(row,col,mod,ene);
+ // none.
+ static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
+ Int_t j,ix,iz;
+ Double_t electronics;
+ Double_t sig;
+ const Int_t nmaxtrk=AliITSdigitSPD::GetNTracks();
+ static AliITSdigitSPD dig;
+ AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
+ if(GetDebug(1)) Info("pListToDigits","()");
+ for(iz=0; iz<GetNPixelsZ(); iz++) for(ix=0; ix<GetNPixelsX(); ix++){
+// NEW (for the moment plugged by hand, in the future possibly read from Data Base)
+// here parametrize the efficiency of the pixel along the row for the test columns (1,9,17,25)
+// if(iz==1 || iz == 9 || iz == 17 || iz == 25) {
+// Double_t eff,p1=0.,p2=0.;
+// Double_t x=ix;
+// switch (iz) {
+// case 1: p1=0.63460;p2=0.42438E-01;break;
+// case 9: p1=0.41090;p2=0.75914E-01;break;
+// case 17: p1=0.31883;p2=0.91502E-01;break;
+// case 25: p1=0.48828;p2=0.57975E-01;break;
+// } // end switch
+// eff=1.-p1*exp(-p2*x);
+// if (gRandom->Rndm() >= eff) continue;
+// } // end if
+ // END parametrize the efficiency
+ //
+ electronics = res->ApplyBaselineAndNoise();
+ UpdateMapNoise(ix,iz,electronics);
+ //
+ // Apply Threshold and write Digits.
+ sig = GetMap()->GetSignalOnly(iz,ix);
+ FillHistograms(ix,iz,sig+electronics);
+ if(GetDebug(3)){
+ cout<<sig<<"+"<<electronics<<">threshold("<<ix<<","<<iz
+ <<")="<<GetThreshold() <<endl;
+ } // end if GetDebug
+ if (sig+electronics <= GetThreshold()) continue;
+ dig.SetCoord1(iz);
+ dig.SetCoord2(ix);
+ dig.SetSignal(1);
+ dig.SetSignalSPD((Int_t) GetMap()->GetSignal(iz,ix));
+ for(j=0;j<nmaxtrk;j++){
+ if (j<GetMap()->GetNEntries()) {
+ dig.SetTrack(j,GetMap()->GetTrack(iz,ix,j));
+ dig.SetHit(j,GetMap()->GetHit(iz,ix,j));
+ }else { // Default values
+ dig.SetTrack(j,-3);
+ dig.SetHit(j,-1);
+ } // end if GetMap()
+ } // end for j
+ if(GetDebug(3)){
+ cout<<iz<<","<<ix<<","<<*(GetMap()->GetpListItem(iz,ix))<<endl;
+ } // end if GetDebug
+ aliITS->AddSimDigit(0,&dig);
+ } // for ix/iz
}
//______________________________________________________________________
-void AliITSsimulationSPD::HitsToAnalogDigits(AliITSmodule *mod,
- Int_t *frowpixel,Int_t *fcolpixel,
- Double_t *fenepixel,
- AliITSpList *pList) {
- // Loops over all hits to produce Analog/floting point digits. This
- // is also the first task in producing standard digits.
+void AliITSsimulationSPD::CreateHistograms(){
+ // create 1D histograms for tests
// Inputs:
- // AliITSmodule *mod module class
- // Int_t *frowpixel array of pixel rows
- // Int_t *fcolpixel array of pixel columns
- // Double_t *fenepiexel array of pixel energies
- // AliITSpList *pList the array of SDigits
+ // none.
// Outputs:
- // AliITSpList *pList the array of SDigits
+ // none.
// Return:
- // none.
-
- // loop over hits in the module
- Int_t hitpos,nhits = mod->GetNhits();
- for (hitpos=0;hitpos<nhits;hitpos++) {
- HitToDigit(mod,hitpos,frowpixel,fcolpixel,fenepixel,pList);
- }// end loop over digits
+ // none.
+
+ if(GetDebug(1)) Info("CreateHistograms","create histograms");
+
+ fHis = new TObjArray(GetNPixelsZ());
+ TString fSPDname("spd_");
+ for(Int_t i=0;i<GetNPixelsZ();i++) {
+ Char_t pixelz[4];
+ sprintf(pixelz,"%d",i);
+ fSPDname.Append(pixelz);
+ fHis->AddAt(new TH1F(fSPDname.Data(),"SPD maps",
+ GetNPixelsX(),0.,(Double_t)GetNPixelsX()),i);
+ } // end for i
}
//______________________________________________________________________
-void AliITSsimulationSPD::HitToDigit(AliITSmodule *mod,Int_t hitpos,
- Int_t *frowpixel,Int_t *fcolpixel,
- Double_t *fenepixel,AliITSpList *pList) {
- // Steering function to determine the digits associated to a given
- // hit (hitpos)
- // The digits are created by charge sharing (ChargeSharing) and by
- // capacitive coupling (SetCoupling). At all the created digits is
- // associated the track number of the hit (ntrack)
+void AliITSsimulationSPD::FillHistograms(Int_t ix,Int_t iz,Double_t v){
+ // Fill the histogram
// Inputs:
- // AliITSmodule *mod module class
- // Int_t hitpos hit index value
- // Int_t *frowpixel array of pixel rows
- // Int_t *fcolpixel array of pixel columns
- // Double_t *fenepiexel array of pixel energies
- // AliITSpList *pList the array of SDigits
+ // none.
// Outputs:
- // AliITSpList *pList the array of SDigits
+ // none.
// Return:
- // none.
- Double_t x1l=0.0,y1l=0.0,z1l=0.0,x2l=0.0,y2l=0.0,z2l=0.0;
- Int_t r1,r2,c1,c2,row,col,npixel = 0;
- Int_t ntrack;
- Double_t ene=0.0,etot=0.0;
- const Float_t kconv = 10000.; // cm -> microns
- const Float_t kconv1= 0.277e9; // GeV -> electrons equivalent
-
- if(!(mod->LineSegmentL(hitpos,x1l,x2l,y1l,y2l,z1l,z2l,etot,ntrack)))return;
-
- x2l += x1l; y2l += y1l; z2l += z1l; // Convert to ending coordinate.
- // positions shifted and converted in microns
- x1l = x1l*kconv + GetSegmentationModel(0)->Dx()/2.;
- z1l = z1l*kconv + GetSegmentationModel(0)->Dz()/2.;
- // positions shifted and converted in microns
- x2l = x2l*kconv + GetSegmentationModel(0)->Dx()/2.;
- z2l = z2l*kconv + GetSegmentationModel(0)->Dz()/2.;
- etot *= kconv1; // convert from GeV to electrons equivalent.
- Int_t module = mod->GetIndex();
-
- // to account for the effective sensitive area
- // introduced in geometry
- if (z1l<0 || z1l>GetSegmentationModel(0)->Dz()) return;
- if (z2l<0 || z2l>GetSegmentationModel(0)->Dz()) return;
- if (x1l<0 || x1l>GetSegmentationModel(0)->Dx()) return;
- if (x2l<0 || x2l>GetSegmentationModel(0)->Dx()) return;
-
- //Get the col and row number starting from 1
- // the x direction is not inverted for the second layer!!!
- GetSegmentationModel(0)->GetPadIxz(x1l, z1l, c1, r1);
- GetSegmentationModel(0)->GetPadIxz(x2l, z2l, c2, r2);
-
- // to account for unexpected equal entrance and
- // exit coordinates
- if (x1l==x2l) x2l=x2l+x2l*0.1;
- if (z1l==z2l) z2l=z2l+z2l*0.1;
-
- if ((r1==r2) && (c1==c2)){
- // no charge sharing
- npixel = 1;
- frowpixel[npixel-1] = r1;
- fcolpixel[npixel-1] = c1;
- fenepixel[npixel-1] = etot;
- } else {
- // charge sharing
- ChargeSharing(x1l,z1l,x2l,z2l,c1,r1,c2,r2,etot,
- npixel,frowpixel,fcolpixel,fenepixel);
- } // end if r1==r2 && c1==c2.
-
- for (Int_t npix=0;npix<npixel;npix++){
- row = frowpixel[npix];
- col = fcolpixel[npix];
- ene = fenepixel[npix];
- UpdateMapSignal(row,col,ntrack,hitpos,module,ene,pList);
- // Starting capacitive coupling effect
- SetCoupling(row,col,ntrack,hitpos,module,pList);
- } // end for npix
+ // none.
+
+ if(!GetHistArray()) return; // Only fill if setup.
+ if(GetDebug(2)) Info("FillHistograms","fill histograms");
+ GetHistogram(iz)->Fill(ix,v);
}
//______________________________________________________________________
-void AliITSsimulationSPD::ChargeSharing(Float_t x1l,Float_t z1l,Float_t x2l,
- Float_t z2l,Int_t c1,Int_t r1,Int_t c2,
- Int_t r2,Float_t etot,
- Int_t &npixel,Int_t *frowpixel,
- Int_t *fcolpixel,Double_t *fenepixel){
- // Take into account the geometrical charge sharing when the track
- // crosses more than one pixel.
+void AliITSsimulationSPD::ResetHistograms(){
+ // Reset histograms for this detector
// Inputs:
- // Float_t x1l
- // Float_t z1l
- // Float_t x2l
- // Float_t z2l
- // Int_t c1
- // Int_t r1
- // Int_t c2
- // Int_t r2
- // Float_t etot
- // Int_t &npixel
- // Int_t *frowpixel array of pixel rows
- // Int_t *fcolpixel array of pixel columns
- // Double_t *fenepiexel array of pixel energies
+ // none.
// Outputs:
- // Int_t &npixel
+ // none.
// Return:
- // none.
- //
- //Begin_Html
- /*
- <img src="picts/ITS/barimodel_2.gif">
- </pre>
- <br clear=left>
- <font size=+2 color=red>
- <a href="mailto:Rocco.Caliandro@ba.infn.it"></a>.
- </font>
- <pre>
- */
- //End_Html
- //Float_t dm;
- Float_t xa,za,xb,zb,dx,dz,dtot,refr,refm,refc;
- Float_t refn=0.;
- Float_t arefm, arefr, arefn, arefc, azb, az2l, axb, ax2l;
- Int_t dirx,dirz,rb,cb;
- Int_t flag,flagrow,flagcol;
- Double_t epar;
-
- npixel = 0;
- xa = x1l;
- za = z1l;
-// dx = x1l-x2l;
-// dz = z1l-z2l;
- dx = x2l-x1l;
- dz = z2l-z1l;
- dtot = TMath::Sqrt((dx*dx)+(dz*dz));
- if (dtot==0.0) dtot = 0.01;
- dirx = (Int_t) TMath::Sign((Float_t)1,dx);
- dirz = (Int_t) TMath::Sign((Float_t)1,dz);
-
- // calculate the x coordinate of the pixel in the next column
- // and the z coordinate of the pixel in the next row
- Float_t xpos, zpos;
-
- GetSegmentationModel(0)->GetPadCxz(c1, r1-1, xpos, zpos);
-
- Float_t xsize = GetSegmentationModel(0)->Dpx(0);
- Float_t zsize = GetSegmentationModel(0)->Dpz(r1-1);
-
- if (dirx == 1) refr = xpos+xsize/2.;
- else refr = xpos-xsize/2.;
-
- if (dirz == 1) refn = zpos+zsize/2.;
- else refn = zpos-zsize/2.;
-
- flag = 0;
- flagrow = 0;
- flagcol = 0;
- do{
- // calculate the x coordinate of the intersection with the pixel
- // in the next cell in row direction
- if(dz!=0)
- refm = dx*((refn - z1l)/dz) + x1l;
- else
- refm = refr+dirx*xsize;
-
- // calculate the z coordinate of the intersection with the pixel
- // in the next cell in column direction
- if (dx!=0)
- refc = dz*((refr - x1l)/dx) + z1l;
- else
- refc = refn+dirz*zsize;
-
- arefm = refm * dirx;
- arefr = refr * dirx;
- arefn = refn * dirz;
- arefc = refc * dirz;
-
- if ((arefm < arefr) && (arefn < arefc)){
- // the track goes in the pixel in the next cell in row direction
- xb = refm;
- zb = refn;
- cb = c1;
- rb = r1 + dirz;
- azb = zb * dirz;
- az2l = z2l * dirz;
- if (rb == r2) flagrow=1;
- if (azb > az2l) {
- zb = z2l;
- xb = x2l;
- } // end if
- // shift to the pixel in the next cell in row direction
- Float_t zsizeNext = GetSegmentationModel(0)->Dpz(rb-1);
- //to account for cell at the borders of the detector
- if(zsizeNext==0) zsizeNext = zsize;
- refn += zsizeNext*dirz;
- }else {
- // the track goes in the pixel in the next cell in column direction
- xb = refr;
- zb = refc;
- cb = c1 + dirx;
- rb = r1;
- axb = xb * dirx;
- ax2l = x2l * dirx;
- if (cb == c2) flagcol=1;
- if (axb > ax2l) {
- zb = z2l;
- xb = x2l;
- } // end ifaxb > ax2l
-
- // shift to the pixel in the next cell in column direction
- Float_t xsizeNext = GetSegmentationModel(0)->Dpx(cb-1);
- //to account for cell at the borders of the detector
- if(xsizeNext==0) xsizeNext = xsize;
- refr += xsizeNext*dirx;
- } // end if (arefm < arefr) && (arefn < arefc)
-
- //calculate the energy lost in the crossed pixel
- epar = TMath::Sqrt((xb-xa)*(xb-xa)+(zb-za)*(zb-za));
- epar = etot*(epar/dtot);
-
- //store row, column and energy lost in the crossed pixel
- frowpixel[npixel] = r1;
- fcolpixel[npixel] = c1;
- fenepixel[npixel] = epar;
- npixel++;
-
- // the exit point of the track is reached
- if (epar == 0) flag = 1;
- if ((r1 == r2) && (c1 == c2)) flag = 1;
- if (flag!=1) {
- r1 = rb;
- c1 = cb;
- xa = xb;
- za = zb;
- } // end if flag!=1
- } while (flag==0);
+ // none.
+
+ if(!GetHistArray()) return; // Only fill if setup.
+ if(GetDebug(2)) Info("FillHistograms","fill histograms");
+ for ( int i=0;i<GetNPixelsZ();i++ ) {
+ if (fHis->At(i)) ((TH1F*)fHis->At(i))->Reset();
+ } // end for i
}
+
//______________________________________________________________________
void AliITSsimulationSPD::SetCoupling(Int_t row, Int_t col, Int_t ntrack,
- Int_t idhit,Int_t module,
- AliITSpList *pList) {
+ Int_t idhit) {
// Take into account the coupling between adiacent pixels.
// The parameters probcol and probrow are the probability of the
// signal in one pixel shared in the two adjacent pixels along
// the column and row direction, respectively.
- // Inputs:
- // Int_t row pixel row number
- // Int_t col pixel column number
- // Int_t ntrack track number of track contributing to this signal
- // Int_t idhit hit number of hit contributing to this signal
- // Int_t module module number
- // AliITSpList *pList the array of SDigits
- // Outputs:
- // AliITSpList *pList the array of SDigits
- // Return:
- // none.
- //
+ // Note pList is goten via GetMap() and module is not need any more.
+ // Otherwise it is identical to that coded by Tiziano Virgili (BSN).
//Begin_Html
/*
<img src="picts/ITS/barimodel_3.gif">
<pre>
*/
//End_Html
+ // Inputs:
+ // Int_t row z cell index
+ // Int_t col x cell index
+ // Int_t ntrack track incex number
+ // Int_t idhit hit index number
+ // Outputs:
+ // none.
+ // Return:
+ // none.
Int_t j1,j2,flag=0;
Double_t pulse1,pulse2;
Double_t couplR=0.0,couplC=0.0;
Double_t xr=0.;
- GetCouplings(couplR,couplC);
+ GetCouplings(couplC,couplR);
+ if(GetDebug(3)) Info("SetCoupling","(row=%d,col=%d,ntrack=%d,idhit=%d) "
+ "Calling SetCoupling couplR=%e couplC=%e",
+ row,col,ntrack,idhit,couplR,couplC);
j1 = row;
j2 = col;
- pulse1 = fMapA2->GetSignal(row,col);
+ pulse1 = GetMap()->GetSignalOnly(row,col);
pulse2 = pulse1;
for (Int_t isign=-1;isign<=1;isign+=2){// loop in row direction
do{
j1 += isign;
// pulse1 *= couplR;
xr = gRandom->Rndm();
- //if ((j1<0) || (j1>GetNPixelsZ()-1) || (pulse1<GetThreshold())){
+ //if ((j1<0)||(j1>GetNPixelsZ()-1)||(pulse1<GetThreshold())){
if ((j1<0) || (j1>GetNPixelsZ()-1) || (xr>couplR)){
j1 = row;
flag = 1;
}else{
- UpdateMapSignal(j1,col,ntrack,idhit,module,pulse1,pList);
+ UpdateMapSignal(col,j1,ntrack,idhit,pulse1);
// flag = 0;
flag = 1; // only first next!!
} // end if
j2 += isign;
// pulse2 *= couplC;
xr = gRandom->Rndm();
- //if ((j2<0) || (j2>(GetNPixelsX()-1)) || (pulse2<GetThreshold())){
+ //if((j2<0)||j2>(GetNPixelsX()-1)||pulse2<GetThreshold()){
if ((j2<0) || (j2>GetNPixelsX()-1) || (xr>couplC)){
j2 = col;
flag = 1;
}else{
- UpdateMapSignal(row,j2,ntrack,idhit,module,pulse2,pList);
+ UpdateMapSignal(j2,row,ntrack,idhit,pulse2);
// flag = 0;
flag = 1; // only first next!!
} // end if
} // for isign
}
//______________________________________________________________________
-void AliITSsimulationSPD::SetCouplingOld(Int_t row, Int_t col, Int_t ntrack,
- Int_t idhit,Int_t module,
- AliITSpList *pList) {
+void AliITSsimulationSPD::SetCouplingOld(Int_t row, Int_t col,
+ Int_t ntrack,Int_t idhit) {
// Take into account the coupling between adiacent pixels.
// The parameters probcol and probrow are the fractions of the
// signal in one pixel shared in the two adjacent pixels along
// the column and row direction, respectively.
- // Inputs:
- // Int_t row pixel row number
- // Int_t col pixel column number
- // Int_t ntrack track number of track contributing to this pixel
- // Int_t idhit hit index number of hit contributing to this pixel
- // Int_t module module number
- // AliITSpList *pList the array of SDigits
- // Outputs:
- // AliITSpList *pList the array of SDigits
- // Return:
- // none.
- //
//Begin_Html
/*
<img src="picts/ITS/barimodel_3.gif">
<pre>
*/
//End_Html
+ // Inputs:
+ // Int_t row z cell index
+ // Int_t col x cell index
+ // Int_t ntrack track incex number
+ // Int_t idhit hit index number
+ // Int_t module module number
+ // Outputs:
+ // none.
+ // Return:
+ // none.
Int_t j1,j2,flag=0;
Double_t pulse1,pulse2;
Double_t couplR=0.0,couplC=0.0;
- GetCouplings(couplR,couplC);
+ GetCouplings(couplC,couplR);
+
+ // Debugging ...
+// cout << "Threshold --> " << GetThreshold() << endl; // dom
+// cout << "Couplings --> " << couplC << " " << couplR << endl; //dom
+
+
+ if(GetDebug(3)) Info("SetCouplingOld","(row=%d,col=%d,ntrack=%d,idhit=%d) "
+ "Calling SetCoupling couplR=%e couplC=%e",
+ row,col,ntrack,idhit,couplR,couplC);
+ for (Int_t isign=-1;isign<=1;isign+=2){// loop in row direction
+ pulse1 = GetMap()->GetSignalOnly(row,col);
+ pulse2 = pulse1;
j1 = row;
j2 = col;
- pulse1 = fMapA2->GetSignal(row,col);
- pulse2 = pulse1;
- for (Int_t isign=-1;isign<=1;isign+=2){// loop in row direction
do{
j1 += isign;
pulse1 *= couplR;
- if ((j1<0) || (j1>GetNPixelsZ()-1) || (pulse1<GetThreshold())){
- pulse1 = fMapA2->GetSignal(row,col);
+ if ((j1<0)||(j1>GetNPixelsZ()-1)||(pulse1<GetThreshold())){
+ pulse1 = GetMap()->GetSignalOnly(row,col);
j1 = row;
flag = 1;
}else{
- UpdateMapSignal(j1,col,ntrack,idhit,module,pulse1,pList);
- flag = 0;
+ UpdateMapSignal(col,j1,ntrack,idhit,pulse1);
+ // flag = 0;
+ flag = 1; // only first next !!
} // end if
} while(flag == 0);
// loop in column direction
do{
j2 += isign;
pulse2 *= couplC;
- if ((j2<0) || (j2>(GetNPixelsX()-1)) || (pulse2<GetThreshold())){
- pulse2 = fMapA2->GetSignal(row,col);
+ if((j2<0)||(j2>(GetNPixelsX()-1))||(pulse2<GetThreshold())){
+ pulse2 = GetMap()->GetSignalOnly(row,col);
j2 = col;
flag = 1;
}else{
- UpdateMapSignal(row,j2,ntrack,idhit,module,pulse2,pList);
- flag = 0;
+ UpdateMapSignal(j2,row,ntrack,idhit,pulse2);
+ // flag = 0;
+ flag = 1; // only first next!!
} // end if
} while(flag == 0);
} // for isign
}
-//______________________________________________________________________
-void AliITSsimulationSPD::CreateDigit(Int_t module,AliITSpList *pList) {
- // The pixels are fired if the energy deposited inside them is above
- // the threshold parameter ethr. Fired pixed are interpreted as digits
- // and stored in the file digitfilename. One also needs to write out
- // cases when there is only noise (nhits==0).
- // Inputs:
- // Int_t module
- // AliITSpList *pList the array of SDigits
- // Outputs:
- // AliITSpList *pList the array of SDigits
- // Return:
- // none.
-
- static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
-
- Int_t size = AliITSdigitSPD::GetNTracks();
- Int_t * digits = new Int_t[size];
- Int_t * tracks = new Int_t[size];
- Int_t * hits = new Int_t[size];
- Float_t * charges = new Float_t[size];
- Int_t j1;
-
- module=0; // remove unused variable warning.
- for(j1=0;j1<size;j1++){tracks[j1]=-3;hits[j1]=-1;charges[j1]=0.0;}
- for (Int_t r=1;r<=GetNPixelsZ();r++) {
- for (Int_t c=1;c<=GetNPixelsX();c++) {
- // check if the deposited energy in a pixel is above the
- // threshold
- Float_t signal = (Float_t) fMapA2->GetSignal(r,c);
- if ( signal > GetThreshold()) {
- digits[0] = r-1; // digits starts from 0
- digits[1] = c-1; // digits starts from 0
- //digits[2] = 1;
- digits[2] = (Int_t) signal; // the signal is stored in
- // electrons
- for(j1=0;j1<size;j1++){
- if(j1<pList->GetNEntries()){
- tracks[j1] = pList->GetTrack(r,c,j1);
- hits[j1] = pList->GetHit(r,c,j1);
- //}else{
- //tracks[j1] = -3;
- //hits[j1] = -1;
- } // end if
- //charges[j1] = 0;
- } // end for j1
- Float_t phys = 0;
- aliITS->AddSimDigit(0,phys,digits,tracks,hits,charges);
- AliDebug(1,Form("mod=%d r,c=%d,%d sig=%f noise=%f Msig=%d Thres=%f",
- fModule,r,c,fpList->GetSignalOnly(r,c),fpList->GetNoise(r,c),
- signal,GetThreshold()));
- } // end if of threshold condition
- } // for c
- }// end do on pixels
- delete [] digits;
- delete [] tracks;
- delete [] hits;
- delete [] charges;
-}
-//______________________________________________________________________
-void AliITSsimulationSPD::SetFluctuations(AliITSpList *pList,Int_t module) {
- // Set the electronic noise and threshold non-uniformities to all the
- // pixels in a detector.
- // The parameter fSigma is the squared sum of the sigma due to noise
- // and the sigma of the threshold distribution among pixels.
- // Inputs:
- // Int_t module modulel number
- // AliITSpList *pList the array of SDigits
- // Outputs:
- // AliITSpList *pList the array of SDigits
- // Return:
- // none.
- //
- //Begin_Html
- /*
- <img src="picts/ITS/barimodel_1.gif">
- </pre>
- <br clear=left>
- <font size=+2 color=red>
- <a href="mailto:Rocco.Caliandro@ba.infn.it"></a>.
- </font>
- <pre>
- */
- //End_Html
- Double_t thr=0.0,sigm=0.0;
- Double_t signal,sigma;
- Int_t iz,ix;
-
- GetThresholds(thr,sigm);
- sigma = (Double_t) sigm;
- for(iz=1;iz<=GetNPixelsZ();iz++){
- for(ix=1;ix<=GetNPixelsX();ix++){
- signal = sigma*gRandom->Gaus();
- fMapA2->SetHit(iz,ix,signal);
- // insert in the label-signal-hit list the pixels fired
- // only by noise
- pList->AddNoise(iz,ix,module,signal);
- } // end of loop on pixels
- } // end of loop on pixels
-}
-
-
-
-//______________________________________________________________________
-void AliITSsimulationSPD::SetMask(Int_t mod) {
- // Apply a mask to the SPD module. 1% of the pixel channels are
- // masked. When the database will be ready, the masked pixels
- // should be read from it.
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
- Double_t signal;
- Int_t iz,ix,im;
- Float_t totMask;
- Float_t perc = ((AliITSCalibrationSPD*)GetCalibrationModel(mod))->GetFractionDead();
- // in this way we get the same set of random numbers for all runs.
- // This is a cluge for now.
- static TRandom *rnd = new TRandom();
-
- totMask= perc*GetNPixelsZ()*GetNPixelsX();
- for(im=1;im<totMask;im++){
- do{
- ix=(Int_t)(rnd->Rndm()*(GetNPixelsX()-1.) + 1.);
- } while(ix<=0 || ix>GetNPixelsX());
- do{
- iz=(Int_t)(rnd->Rndm()*(GetNPixelsZ()-1.) + 1.);
- } while(iz<=0 || iz>GetNPixelsZ());
- signal = -1.;
- fMapA2->SetHit(iz,ix,signal);
- } // end loop on masked pixels
-}
-//______________________________________________________________________
-void AliITSsimulationSPD::CreateHistograms() {
- // Create Histograms
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
- Int_t i;
-
- fHis=new TObjArray(GetNPixelsZ());
- for(i=0;i<GetNPixelsZ();i++) {
- TString spdname("spd_");
- Char_t candnum[4];
- sprintf(candnum,"%d",i+1);
- spdname.Append(candnum);
- (*fHis)[i] = new TH1F(spdname.Data(),"SPD maps",
- GetNPixelsX(),0.,(Float_t) GetNPixelsX());
- } // end for i
-}
-//______________________________________________________________________
-void AliITSsimulationSPD::ResetHistograms() {
- // Reset histograms for this detector
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
- Int_t i;
-
- for(i=0;i<GetNPixelsZ();i++ ) {
- if ((*fHis)[i]) ((TH1F*)(*fHis)[i])->Reset();
- } // end for i
-}
-//______________________________________________________________________
-void AliITSsimulationSPD::WriteSDigits(AliITSpList *pList){
- // Fills the Summable digits Tree
- // Inputs:
- // AliITSpList *pList the array of SDigits
- // Outputs:
- // AliITSpList *pList the array of SDigits
- // Return:
- // none.
- Int_t i,ni,j,nj;
- static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
-
- pList->GetMaxMapIndex(ni,nj);
- for(i=0;i<ni;i++)for(j=0;j<nj;j++){
- if(pList->GetSignalOnly(i,j)>0.0){
- aliITS->AddSumDigit(*(pList->GetpListItem(i,j)));
- if(AliDebugLevel()>0){
- cout << "pListSPD: " << *(pList->GetpListItem(i,j)) << endl;
- AliDebug(1,Form("mod=%d r,c=%d %d sig=%f noise=%f",
- fModule,i,j,fpList->GetSignalOnly(i,j),fpList->GetNoise(i,j)))
- } // end if GetDebug
- } // end if
- } // end for i,j
- return;
-}
-//______________________________________________________________________
-void AliITSsimulationSPD::FillMapFrompList(AliITSpList *pList){
- // Fills fMap2A from the pList of Summable digits
- // Inputs:
- // AliITSpList *pList the array of SDigits
- // Outputs:
- // AliITSpList *pList the array of SDigits
- // Return:
- // none.
- Int_t ix,iz;
-
- for(iz=0;iz<GetNPixelsZ();iz++)for(ix=0;ix<GetNPixelsX();ix++)
- fMapA2->AddSignal(iz,ix,pList->GetSignal(iz,ix));
- return;
-}
#ifndef ALIITSSIMULATIONSPD_H
#define ALIITSSIMULATIONSPD_H
+
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* See cxx source for full Copyright notice */
-/*
-$Id$
-*/
-////////////////////////////////////////////////////////////////////////
-// Version: 0 //
-// Written by Rocco Caliandro //
-// from a model developed with T. Virgili and R.A. Fini //
-// June 15 2000 //
-// //
-// AliITSsimulationSPD is the simulation of SPDs //
-////////////////////////////////////////////////////////////////////////
-
+#include "TH1F.h"
+#include "TObjArray.h"
+#include "AliITSsimulation.h"
#include "AliITSCalibrationSPD.h"
#include "AliITSsegmentationSPD.h"
-#include "AliITSsimulation.h"
#include "AliITSresponseSPD.h"
+#include "AliCDBEntry.h"
+#include "AliCDBLocal.h"
-class AliITSMapA2;
-class AliITSpList;
class AliITSmodule;
//-------------------------------------------------------------------
class AliITSsimulationSPD : public AliITSsimulation {
-
- public:
- AliITSsimulationSPD(); // Default constructor
- // Standard constructor
+ public:
+ AliITSsimulationSPD();
+ // AliITSsimulationSPD(AliITSsegmentation *seg,AliITSCalibration *res);
AliITSsimulationSPD(AliITSDetTypeSim *dettyp);
- virtual ~AliITSsimulationSPD();// destructor
- AliITSsimulationSPD(const AliITSsimulationSPD &source); // copy constructo
- // assignment operator
- AliITSsimulationSPD& operator=(const AliITSsimulationSPD &source);
+ virtual ~AliITSsimulationSPD();
+ // copy constructor
+ AliITSsimulationSPD(const AliITSsimulationSPD &source);
+ // ass. operator
+ AliITSsimulationSPD& operator=(const AliITSsimulationSPD &s);
virtual AliITSsimulation& operator=(const AliITSsimulation &source);
- // Get a pointer to the segmentation object
- virtual AliITSsegmentation* GetSegmentationModel(Int_t /*dt*/){return fDetType->GetSegmentationModel(0);}
- // set pointer to segmentation objec
- virtual void SetSegmentationModel(Int_t /*dt*/, AliITSsegmentation *seg){fDetType->SetSegmentationModel(0,seg);}
// Initilizes the variables
void Init();
- // Initilizes the variables with replacement segmentation/response class
- // void Init(AliITSsegmentationSPD *seg, AliITSCalibrationSPD *resp);
+ // Get pointers (calObj[]) to the calibration objects
+ // ??? Is there a better way to do this ???
+ void GetCalibrationObjects(Int_t RunNr);
- // Sum digitize module
- // Create maps to build the lists of tracks for each summable digit
- void InitSimulationModule(Int_t module,Int_t events);
- // Digitize module from the sum of summable digits.
+ // General User calling routines
+ // Initilize simulation for a specific event and module
+ void InitSimulationModule(Int_t module, Int_t event);
+ // Finish and write S Digitization
void FinishSDigitiseModule();
- void SDigitiseModule(AliITSmodule *mod, Int_t dummy0,Int_t dummy1);
- // digitize module. Also need to digitize modules with only noise.
- void DigitiseModule(AliITSmodule *mod,Int_t dummy0, Int_t dummy1);
- // sum digits to Digits.
- void SDigitsToDigits(Int_t module,AliITSpList *pList);
- // updates the Map of signal, adding the energy (ene) released by
- // the current track
- void UpdateMapSignal(Int_t row,Int_t col,Int_t trk,Int_t hit,Int_t mod,
- Double_t ene,AliITSpList *pList);
- // updates the Map of noise, adding the energy (ene) give my noise
- void UpdateMapNoise(Int_t row,Int_t col,Int_t mod,Double_t ene,
- AliITSpList *pList);
- // Loops over all hits to produce Analog/floting point digits. This
- // is also the first task in producing standard digits.
- void HitsToAnalogDigits(AliITSmodule *mod,Int_t *frowpixel,
- Int_t *fcolpixel,Double_t *fenepixel,
- AliITSpList *pList);
- // Steering function to determine the digits associated to a given
- // hit (hitpos)
- // The digits are created by charge sharing (ChargeSharing) and by
- // capacitive coupling (SetCoupling). At all the created digits is
- // associated the track number of the hit (ntrack)
- void HitToDigit(AliITSmodule *mod, Int_t hitpos,Int_t *frowpixel,
- Int_t *fcolpixel, Double_t *fenepixel,AliITSpList *pList);
- // Take into account the geometrical charge sharing when the track
- // crosses more than one pixel.
- void ChargeSharing(Float_t x1l,Float_t z1l,Float_t x2l,Float_t z2l,
- Int_t c1,Int_t r1,Int_t c2,Int_t r2,Float_t etot,
- Int_t &npixel,Int_t *frowpixel,Int_t *fcolpixel,
- Double_t *fenepixel);
- // Take into account the coupling between adiacent pixels.
- // The parameters probcol and probrow are the fractions of the
- // signal in one pixel shared in the two adjacent pixels along
- // the column and row direction, respectively. Now done in a statistical
- // way and not "mechanical" as in the Old version.
- void SetCoupling(Int_t row,Int_t col,Int_t ntrack,Int_t idhit,Int_t module,
- AliITSpList *pList);
- // Take into account the coupling between adiacent pixels.
- // The parameters probcol and probrow are the fractions of the
- // signal in one pixel shared in the two adjacent pixels along
- // the column and row direction, respectively.
- void SetCouplingOld(Int_t row,Int_t col,Int_t ntrack,Int_t idhit,
- Int_t module,AliITSpList *pList);
- // The pixels are fired if the energy deposited inside them is above
- // the threshold parameter ethr. Fired pixed are interpreted as digits
- // and stored in the file digitfilename. One also needs to write out
- // cases when there is only noise (nhits==0).
- void CreateDigit(Int_t module,AliITSpList *pList);
- // Set the electronic noise and threshold non-uniformities to all the
- // pixels in a detector.
- // The parameter fSigma is the squared sum of the sigma due to noise
- // and the sigma of the threshold distribution among pixels.
- void SetFluctuations(AliITSpList *pList,Int_t module);
- // Apply a mask to the SPD module. 1% of the pixel channels are
- // masked. When the database will be ready, the masked pixels
- // should be read from it.
- void SetMask(Int_t mod);
- // Create Histograms
+ // From hits to Digits, without creating SDigits
+ void DigitiseModule(AliITSmodule *mod,Int_t,Int_t);
+
+ // More or less Internal Routines
+ // Create S Digits from specific module
+ void SDigitiseModule(AliITSmodule *mod, Int_t mask, Int_t event);
+ // Write S Digits to the tree of SDigits.
+ void WriteSDigits();
+ // fill pList from hits, charge sharing, diffusion, coupling
+ void HitToSDigit(AliITSmodule *mod);
+ // fill pList from hits, charge sharing, diffusion, coupling (faster method optimized by Bjorne)
+ void HitToSDigitFast(AliITSmodule *mod);
+ // Removes dead pixels from pList
+ void RemoveDeadPixels(AliITSmodule *mod);
+ // Take pList of signals and apply noise... create Digis
+ void pListToDigits();
+ //
void CreateHistograms();
- // Reset histograms for this detector
+ void FillHistograms(Int_t ix,Int_t iz,Double_t v=1.0);
void ResetHistograms();
- // Fills the Summable digits Tree
- void WriteSDigits(AliITSpList *pList);
- // Fills fMap2A from the pList of Summable digits
- void FillMapFrompList(AliITSpList *pList);
- // get hist array
- TObjArray* GetHistArray() {return fHis;}
+ TH1F* GetHistogram(Int_t i){return (TH1F*)(fHis->At(i));}// get histogram
+ TObjArray* GetHistArray() {return fHis;}// get hist array
+ TString& GetHistName(){return fSPDname;}
+ void SetHistName(TString &n){fSPDname = n;}
+ //
+ // For backwards compatibility
+ void SDigitsToDigits(){ FinishSDigitiseModule();};
+ void HitToDigit(AliITSmodule *mod){
+ // Standard interface to DigitiseModule
+ // Inputs:
+ // AliITSmodule *mod Pointer to this module
+ // Outputs:
+ // none.
+ // Return:
+ // none.
+ DigitiseModule(mod,GetModuleNumber(),0);};
private:
+ void SpreadCharge(Double_t x0,Double_t z0,Int_t ix0,Int_t iz0,
+ Double_t el,Double_t sig,Int_t t,Int_t hi);
+ void SpreadChargeAsym(Double_t x0,Double_t z0,Int_t ix0,Int_t iz0,
+ Double_t el,Double_t sigx,Double_t sigz,Int_t t,Int_t hi);
+ void UpdateMapSignal(Int_t ix,Int_t iz,Int_t trk,Int_t ht,Double_t signal){
+ // This function adds a signal to the pList from the pList class
+ // Inputs:
+ // Int_t iz // row number
+ // Int_t ix // column number
+ // Int_t trk // track number
+ // Int_t ht // hit number
+ // Double_t signal // signal strength
+ // Outputs:
+ // none.
+ // Return:
+ // none
+ GetMap()->AddSignal(iz,ix,trk,ht,GetModuleNumber(),signal);};
+ void UpdateMapNoise(Int_t ix,Int_t iz,Float_t noise){
+ // This function adds noise to data in the MapA2 as well as the pList
+ // Inputs:
+ // Int_t iz // row number
+ // Int_t ix // column number
+ // Double_t ns // electronic noise generated by pListToDigits
+ // Outputs:
+ // none.
+ // Return:
+ // none
+ GetMap()->AddNoise(iz,ix,GetModuleNumber(),noise);}
+ // Get a pointer to the segmentation object
+ virtual AliITSsegmentation* GetSegmentationModel(Int_t /*dt*/){return fDetType->GetSegmentationModel(0);}
+ // set pointer to segmentation objec
+ virtual void SetSegmentationModel(Int_t /*dt*/, AliITSsegmentation *seg){fDetType->SetSegmentationModel(0,seg);}
+ // Bari-Salerno Coupling parameters
+ // "New" coupling routine Tiziano Virgili
+ void SetCoupling(Int_t row,Int_t col,Int_t ntrack,Int_t idhit);
+ // "Old" coupling routine Rocco Caliandro
+ void SetCouplingOld(Int_t row, Int_t col,Int_t ntrack,Int_t idhit);
// Getters for data kept in fSegmentation and fResponse.
// Returns the Threshold in electrons
- Double_t GetThreshold(){Double_t a=0.0,b=0.0;
- AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(GetModuleNumber());
- res->Thresholds(a,b); return a;}
- // Returns the threshold and rms noise.
- void GetThresholds(Double_t &t,Double_t &s){
- AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(GetModuleNumber());
- res->Thresholds(t,s);}
+ Double_t GetThreshold(){
+ Double_t th,sig;AliITSCalibrationSPD* res=(AliITSCalibrationSPD*)GetCalibrationModel(GetModuleNumber());
+ res->Thresholds(th,sig);return th;};
// Returns the couplings Columb and Row.
void GetCouplings(Double_t &cc,Double_t &cr){
AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(GetModuleNumber());
- res->GetCouplingParam(cc,cr);}
+ res->GetCouplingParam(cc,cr);};
// Returns the number of pixels in x
- Int_t GetNPixelsX(){AliITSsegmentationSPD* seg= (AliITSsegmentationSPD*)GetSegmentationModel(0);return seg->Npx();}
+ Int_t GetNPixelsX(){return GetSegmentationModel(0)->Npx();};
// Returns the number of pixels in z
- Int_t GetNPixelsZ(){AliITSsegmentationSPD* seg= (AliITSsegmentationSPD*)GetSegmentationModel(0);return seg->Npz();}
-
- private:
- AliITSMapA2 *fMapA2; //! MapA2 for Local internal use only
- TObjArray *fHis; //! just in case for histogramming for Local
- // internal use only
-
- ClassDef(AliITSsimulationSPD,1) // Simulation of SPD clusters
+ Int_t GetNPixelsZ(){return GetSegmentationModel(0)->Npz();};
+ TObjArray *fHis; //! just in case for histogramming
+ TString fSPDname; //! Histogram name
+ Int_t fCoupling; // Sets the coupling to be used.
+ // ==1 use SetCoupling, ==2 use SetCouplingOld
+ AliITSCalibrationSPD* calObj[240];
+ ClassDef(AliITSsimulationSPD,2) // Simulation of SPD clusters
};
-
-#endif
+#endif
+++ /dev/null
-/**************************************************************************
- * 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. *
- * *
- * Permission to use, copy, modify and distribute this software and its *
- * documentation strictly for non-commercial purposes is hereby granted *
- * without fee, provided that the above copyright notice appears in all *
- * copies and that both the copyright notice and this permission notice *
- * appear in the supporting documentation. The authors make no claims *
- * about the suitability of this software for any purpose. It is *
- * provided "as is" without express or implied warranty. *
- **************************************************************************/
-
-/*
-$Id$
-*/
-
-#include <Riostream.h>
-#include <TH1.h>
-#include <TMath.h>
-#include <TParticle.h>
-#include <TRandom.h>
-#include <TString.h>
-#include "AliITS.h"
-#include "AliITSMapA2.h"
-#include "AliITSdigitSPD.h"
-#include "AliITSgeom.h"
-#include "AliITShit.h"
-#include "AliITSmodule.h"
-#include "AliITSpList.h"
-#include "AliITSCalibrationSPD.h"
-#include "AliITSsegmentationSPD.h"
-#include "AliITSsimulationSPDdubna.h"
-#include "AliLog.h"
-#include "AliRun.h"
-
-//#define DEBUG
-
-ClassImp(AliITSsimulationSPDdubna)
-////////////////////////////////////////////////////////////////////////
-// Version: 1
-// Modified by Bjorn S. Nilsen
-// Version: 0
-// Written by Boris Batyunya
-// December 20 1999
-//
-// AliITSsimulationSPDdubna is to do the simulation of SPDs.
-//______________________________________________________________________
-AliITSsimulationSPDdubna::AliITSsimulationSPDdubna():
-AliITSsimulation(),
-fHis(0),
-fSPDname(),
-fCoupling(0){
- // Default constructor.
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // A default constructed AliITSsimulationSPDdubna class.
-
- AliDebug(1,Form("Calling degault constructor"));
-}
-//______________________________________________________________________
-AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(AliITSDetTypeSim *dettyp, Int_t cup):
-AliITSsimulation(dettyp),
-fHis(0),
-fSPDname(),
-fCoupling(cup){
- // standard constructor
- // Inputs:
- // AliITSsegmentation *seg A pointer to the segmentation class
- // to be used for this simulation
- // AliITSCalibration *resp A pointer to the responce class to
- // be used for this simulation
- // Int_t cup The type of coupling to be used
- // =1 uses SetCoupling, =2 uses SetCouplingOld
- // With diffusion tured off
- // =3 uses SetCoupling, =4 uses SetCouplingOld
- // with diffusion on other, no coupling.
- // Outputs:
- // none.
- // Return:
- // A default constructed AliITSsimulationSPDdubna class.
-
- AliDebug(1,
- Form("Calling degault constructor cup=%d",cup));
- if(cup==1||cup==2){ // For the moment, remove defusion if Coupling is
- // set.
- AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
- res->SetTemperature(0.0);
- res->SetDistanceOverVoltage(0.0);
- } // end if
- Init();
-}
-//______________________________________________________________________
-void AliITSsimulationSPDdubna::Init(){
- // Initilization
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
- const Double_t kmictocm = 1.0e-4; // convert microns to cm.
-
- SetModuleNumber(0);
- SetEventNumber(0);
- SetMap(new AliITSpList(GetNPixelsZ(),GetNPixelsX()));
- AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
- AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
- res->SetDistanceOverVoltage(kmictocm*seg->Dy(),50.0);
-}
-//______________________________________________________________________
-AliITSsimulationSPDdubna::~AliITSsimulationSPDdubna(){
- // destructor
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
-
- if (fHis) {
- fHis->Delete();
- delete fHis;
- } // end if fHis
-}
-//______________________________________________________________________
-AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(const
- AliITSsimulationSPDdubna
- &s) : AliITSsimulation(s){
- // Copy Constructor
- // Inputs:
- // AliITSsimulationSPDdubna &s The original class for which
- // this class is a copy of
- // Outputs:
- // none.
- // Return:
-
- *this = s;
- return;
-}
-//______________________________________________________________________
-AliITSsimulationSPDdubna& AliITSsimulationSPDdubna::operator=(const
- AliITSsimulationSPDdubna &s){
- // Assignment operator
- // Inputs:
- // AliITSsimulationSPDdubna &s The original class for which
- // this class is a copy of
- // Outputs:
- // none.
- // Return:
-
- if(&s == this) return *this;
- this->fHis = s.fHis;
- fCoupling = s.fCoupling;
- fSPDname = s.fSPDname;
- return *this;
-}
-//______________________________________________________________________
-AliITSsimulation& AliITSsimulationSPDdubna::operator=(const
- AliITSsimulation &s){
- // Assignment operator
- // Inputs:
- // AliITSsimulationSPDdubna &s The original class for which
- // this class is a copy of
- // Outputs:
- // none.
- // Return:
-
- if(&s == this) return *this;
- Error("AliITSsimulationSPDdubna","Not allowed to make a = with "
- "AliITSsimulationSPDdubna","Using default creater instead");
-
- return *this;
-}
-//______________________________________________________________________
-void AliITSsimulationSPDdubna::InitSimulationModule(Int_t module, Int_t event){
- // This function creates maps to build the list of tracks for each
- // summable digit. Inputs defined by base class.
- // Inputs:
- // Int_t module // Module number to be simulated
- // Int_t event // Event number to be simulated
- // Outputs:
- // none
- // Returns:
- // none
-
- AliDebug(1,Form("(module=%d,event=%d)",module,event));
- SetModuleNumber(module);
- SetEventNumber(event);
- ClearMap();
-}
-//_____________________________________________________________________
-void AliITSsimulationSPDdubna::SDigitiseModule(AliITSmodule *mod,Int_t,
- Int_t event){
- // This function begins the work of creating S-Digits. Inputs defined
- // by base class.
- // Inputs:
- // AliITSmodule *mod // module
- // Int_t // not used
- // Int_t event // Event number
- // Outputs:
- // none
- // Return:
- // test // test returns kTRUE if the module contained hits
- // // test returns kFALSE if it did not contain hits
-
- AliDebug(1,Form("(mod=%p, ,event=%d)",mod,event));
- if(!(mod->GetNhits())){
- AliDebug(1,Form("In event %d module %d there are %d hits returning.",
- event, mod->GetIndex(),mod->GetNhits()));
- return;// if module has no hits don't create Sdigits
- } // end if
- SetModuleNumber(mod->GetIndex());
- SetEventNumber(event);
- HitToSDigit(mod);
- WriteSDigits();
- ClearMap();
-}
-//______________________________________________________________________
-void AliITSsimulationSPDdubna::WriteSDigits(){
- // This function adds each S-Digit to pList
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none
- Int_t ix, nix, iz, niz;
- static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
-
- AliDebug(1,Form("Writing SDigits for module %d",GetModuleNumber()));
- GetMap()->GetMaxMapIndex(niz, nix);
- for(iz=0; iz<niz; iz++)for(ix=0; ix<nix; ix++){
- if(GetMap()->GetSignalOnly(iz,ix)>0.0){
- aliITS->AddSumDigit(*(GetMap()->GetpListItem(iz,ix)));
- if(AliDebugLevel()>0) {
- AliDebug(1,Form("%d, %d",iz,ix));
- cout << *(GetMap()->GetpListItem(iz,ix)) << endl;
- } // end if GetDebug
- } // end if GetMap()->GetSignalOnly(iz,ix)>0.0
- } // end for iz,ix
- return;
-}
-//______________________________________________________________________
-void AliITSsimulationSPDdubna::FinishSDigitiseModule(){
- // This function calls SDigitsToDigits which creates Digits from SDigits
- // Inputs:
- // none
- // Outputs:
- // none
- // Return
- // none
-
- AliDebug(1,"()");
- pListToDigits(); // Charge To Signal both adds noise and
- ClearMap();
- return;
-}
-//______________________________________________________________________
-void AliITSsimulationSPDdubna::DigitiseModule(AliITSmodule *mod,Int_t,
- Int_t){
- // This function creates Digits straight from the hits and then adds
- // electronic noise to the digits before adding them to pList
- // Each of the input variables is passed along to HitToSDigit
- // Inputs:
- // AliITSmodule *mod module
- // Int_t Dummy.
- // Int_t Dummy
- // Outputs:
- // none.
- // Return:
- // none.
-
- AliDebug(1,Form("(mod=%p,,)",mod));
- HitToSDigit(mod);
- pListToDigits();
- ClearMap();
-}
-//______________________________________________________________________
-void AliITSsimulationSPDdubna::HitToSDigit(AliITSmodule *mod){
- // Does the charge distributions using Gaussian diffusion charge charing.
- // Inputs:
- // AliITSmodule *mod Pointer to this module
- // Output:
- // none.
- // Return:
- // none.
- const Double_t kmictocm = 1.0e-4; // convert microns to cm.
- TObjArray *hits = mod->GetHits();
- Int_t nhits = hits->GetEntriesFast();
- Int_t h,ix,iz,i;
- Int_t idtrack;
- Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0;
- Double_t x,y,z,t,tp,st,dt=0.2,el,sig;
- AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
- AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
- Double_t thick = kmictocm*seg->Dy();
-
- AliDebug(1,Form("(mod=%p) fCoupling=%d",mod,fCoupling));
- if(nhits<=0) return;
- for(h=0;h<nhits;h++){
- if(AliDebugLevel()>0) {
- AliDebug(1,Form("Hits, %d", h));
- cout << *(mod->GetHit(h)) << endl;
- } // end if GetDebug
- if(!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue;
- st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
- if(st>0.0){
- st = (Double_t)((Int_t)(st/kmictocm)); // number of microns
- if(st<=1.0) st = 1.0;
- dt = 1.0/st;
- for(t=0.0;t<1.0;t+=dt){ // Integrate over t
- tp = t+0.5*dt;
- x = x0+x1*tp;
- y = y0+y1*tp;
- z = z0+z1*tp;
- if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
- el = res->GeVToCharge((Double_t)(dt*de));
- if(GetDebug(1)){
- if(el<=0.0) cout<<"el="<<el<<" dt="<<dt
- <<" de="<<de<<endl;
- } // end if GetDebug
- sig = res->SigmaDiffusion1D(thick + y);
- SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
- } // end for t
- } else { // st == 0.0 deposit it at this point
- x = x0;
- y = y0;
- z = z0;
- if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
- el = res->GeVToCharge((Double_t)de);
- sig = res->SigmaDiffusion1D(thick + y);
- SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
- } // end if st>0.0
- // Coupling
- switch (fCoupling) {
- default:
- break;
- case 1: case 3:
- // x is column and z is row (see AliITSsegmentationSPD::GetPadIxz)
- for(i=0;i<GetMap()->GetEntries();i++)
- if(GetMap()->GetpListItem(i)==0) continue;
- else{
- GetMap()->GetMapIndex(
- GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
- SetCoupling(iz,ix,idtrack,h);
- } // end for i
- break;
- case 2: case 4:
- // x is column and z is row (see AliITSsegmentationSPD::GetPadIxz)
- for(i=0;i<GetMap()->GetEntries();i++)
- if(GetMap()->GetpListItem(i)==0) continue;
- else{
- GetMap()->GetMapIndex(
- GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
- SetCouplingOld(iz,ix,idtrack,h);
- } // end for i
- break;
- } // end switch
- } // Loop over all hits h
- if(GetDebug(2))Info("HitToSDigit","Finished fCoupling=%d",fCoupling);
-}
-//______________________________________________________________________
-void AliITSsimulationSPDdubna::SpreadCharge(Double_t x0,Double_t z0,
- Int_t ix0,Int_t iz0,
- Double_t el,Double_t sig,Int_t t,
- Int_t hi){
- // Spreads the charge over neighboring cells. Assume charge is distributed
- // as charge(x,z) = (el/2*pi*sig*sig)*exp(-arg)
- // arg=((x-x0)*(x-x0)/2*sig*sig)+((z-z0*z-z0)/2*sig*sig)
- // Defined this way, the integral over all x and z is el.
- // Inputs:
- // Double_t x0 x position of point where charge is liberated
- // Double_t y0 y position of point where charge is liberated
- // Double_t z0 z position of point where charge is liberated
- // Int_t ix0 row of cell corresponding to point x0
- // Int_t iz0 columb of cell corresponding to point z0
- // Double_t el number of electrons liberated in this step
- // Double_t sig Sigma difusion for this step (y0 dependent)
- // Int_t t track number
- // Int_t ti hit track index number
- // Int_t hi hit "hit" index number
- // Outputs:
- // none.
- // Return:
- // none.
- const Int_t knx = 3,knz = 2;
- const Double_t kRoot2 = 1.414213562; // Sqrt(2).
- const Double_t kmictocm = 1.0e-4; // convert microns to cm.
- Int_t ix,iz,ixs,ixe,izs,ize;
- Float_t x,z;
- Double_t x1,x2,z1,z2,s,sp;
- AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
-
-
- if(GetDebug(4)) Info("SpreadCharge","(x0=%e,z0=%e,ix0=%d,iz0=%d,el=%e,"
- "sig=%e,t=%d,i=%d)",x0,z0,ix0,iz0,el,sig,t,hi);
- if(sig<=0.0) { // if sig<=0 No diffusion to simulate.
- GetMap()->AddSignal(iz0,ix0,t,hi,GetModuleNumber(),el);
- if(GetDebug(2)){
- cout << "sig<=0.0=" << sig << endl;
- } // end if GetDebug
- return;
- } // end if
- sp = 1.0/(sig*kRoot2);
- if(GetDebug(2)){
- cout << "sig=" << sig << " sp=" << sp << endl;
- } // end if GetDebug
- ixs = TMath::Max(-knx+ix0,0);
- ixe = TMath::Min(knx+ix0,seg->Npx()-1);
- izs = TMath::Max(-knz+iz0,0);
- ize = TMath::Min(knz+iz0,seg->Npz()-1);
- for(ix=ixs;ix<=ixe;ix++) for(iz=izs;iz<=ize;iz++){
- seg->DetToLocal(ix,iz,x,z); // pixel center
- x1 = x;
- z1 = z;
- x2 = x1 + 0.5*kmictocm*seg->Dpx(ix); // Upper
- x1 -= 0.5*kmictocm*seg->Dpx(ix); // Lower
- z2 = z1 + 0.5*kmictocm*seg->Dpz(iz); // Upper
- z1 -= 0.5*kmictocm*seg->Dpz(iz); // Lower
- x1 -= x0; // Distance from where track traveled
- x2 -= x0; // Distance from where track traveled
- z1 -= z0; // Distance from where track traveled
- z2 -= z0; // Distance from where track traveled
- s = 0.25; // Correction based on definision of Erfc
- s *= TMath::Erfc(sp*x1) - TMath::Erfc(sp*x2);
- if(GetDebug(3)){
- cout <<"el="<<el<<" ix0="<<ix0<<" ix="<<ix<<" x0="<<x<<
- " iz0="<<iz0<<" iz="<<iz<<" z0="<<z<<
- " sp*x1="<<sp*x1<<" sp*x2="<<sp*x2<<" s="<<s;
- } // end if GetDebug
- s *= TMath::Erfc(sp*z1) - TMath::Erfc(sp*z2);
- if(GetDebug(3)){
- cout<<" sp*z1="<<sp*z1<<" sp*z2="<<sp*z2<<" s="<<s<< endl;
- } // end if GetDebug
- GetMap()->AddSignal(iz,ix,t,hi,GetModuleNumber(),s*el);
- } // end for ix, iz
-}
-//______________________________________________________________________
-void AliITSsimulationSPDdubna::pListToDigits(){
- // add noise and electronics, perform the zero suppression and add the
- // digit to the list
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
- static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
- Int_t j,ix,iz;
- Double_t electronics;
- Double_t sig;
- const Int_t nmaxtrk=AliITSdigitSPD::GetNTracks();
- static AliITSdigitSPD dig;
- AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
- if(GetDebug(1)) Info("pListToDigits","()");
- for(iz=0; iz<GetNPixelsZ(); iz++) for(ix=0; ix<GetNPixelsX(); ix++){
- // Apply Noise/Dead channals and the like
- if(res->IsPixelDead(GetModuleNumber(),ix,iz)) continue;
- electronics = res->ApplyBaselineAndNoise();
- UpdateMapNoise(ix,iz,electronics);
- //
- // Apply Threshold and write Digits.
- sig = GetMap()->GetSignalOnly(iz,ix);
- FillHistograms(ix,iz,sig+electronics);
- if(GetDebug(3)){
- cout<<sig<<"+"<<electronics<<">threshold("<<ix<<","<<iz
- <<")="<<GetThreshold() <<endl;
- } // end if GetDebug
- if (sig+electronics <= GetThreshold()) continue;
- dig.SetCoord1(iz);
- dig.SetCoord2(ix);
- dig.SetSignal(1);
- dig.SetSignalSPD((Int_t) GetMap()->GetSignal(iz,ix));
- for(j=0;j<nmaxtrk;j++){
- if (j<GetMap()->GetNEntries()) {
- dig.SetTrack(j,GetMap()->GetTrack(iz,ix,j));
- dig.SetHit(j,GetMap()->GetHit(iz,ix,j));
- }else { // Default values
- dig.SetTrack(j,-3);
- dig.SetHit(j,-1);
- } // end if GetMap()
- } // end for j
- if(GetDebug(3)){
- cout<<iz<<","<<ix<<","<<*(GetMap()->GetpListItem(iz,ix))<<endl;
- } // end if GetDebug
- aliITS->AddSimDigit(0,&dig);
- } // for ix/iz
-}
-//______________________________________________________________________
-void AliITSsimulationSPDdubna::CreateHistograms(){
- // create 1D histograms for tests
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
-
- if(GetDebug(1)) Info("CreateHistograms","create histograms");
-
- fHis = new TObjArray(GetNPixelsZ());
- TString fSPDname("spd_");
- for(Int_t i=0;i<GetNPixelsZ();i++) {
- Char_t pixelz[4];
- sprintf(pixelz,"%d",i);
- fSPDname.Append(pixelz);
- fHis->AddAt(new TH1F(fSPDname.Data(),"SPD maps",
- GetNPixelsX(),0.,(Double_t)GetNPixelsX()),i);
- } // end for i
-}
-//______________________________________________________________________
-void AliITSsimulationSPDdubna::FillHistograms(Int_t ix,Int_t iz,Double_t v){
- // Fill the histogram
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
-
- if(!GetHistArray()) return; // Only fill if setup.
- if(GetDebug(2)) Info("FillHistograms","fill histograms");
- GetHistogram(iz)->Fill(ix,v);
-}
-//______________________________________________________________________
-void AliITSsimulationSPDdubna::ResetHistograms(){
- // Reset histograms for this detector
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
-
- if(!GetHistArray()) return; // Only fill if setup.
- if(GetDebug(2)) Info("FillHistograms","fill histograms");
- for ( int i=0;i<GetNPixelsZ();i++ ) {
- if (fHis->At(i)) ((TH1F*)fHis->At(i))->Reset();
- } // end for i
-}
-
-//______________________________________________________________________
-void AliITSsimulationSPDdubna::SetCoupling(Int_t row, Int_t col, Int_t ntrack,
- Int_t idhit) {
- // Take into account the coupling between adiacent pixels.
- // The parameters probcol and probrow are the probability of the
- // signal in one pixel shared in the two adjacent pixels along
- // the column and row direction, respectively.
- // Note pList is goten via GetMap() and module is not need any more.
- // Otherwise it is identical to that coded by Tiziano Virgili (BSN).
- //Begin_Html
- /*
- <img src="picts/ITS/barimodel_3.gif">
- </pre>
- <br clear=left>
- <font size=+2 color=red>
- <a href="mailto:tiziano.virgili@cern.ch"></a>.
- </font>
- <pre>
- */
- //End_Html
- // Inputs:
- // Int_t row z cell index
- // Int_t col x cell index
- // Int_t ntrack track incex number
- // Int_t idhit hit index number
- // Outputs:
- // none.
- // Return:
- // none.
- Int_t j1,j2,flag=0;
- Double_t pulse1,pulse2;
- Double_t couplR=0.0,couplC=0.0;
- Double_t xr=0.;
-
- GetCouplings(couplR,couplC);
- if(GetDebug(3)) Info("SetCoupling","(row=%d,col=%d,ntrack=%d,idhit=%d) "
- "Calling SetCoupling couplR=%e couplC=%e",
- row,col,ntrack,idhit,couplR,couplC);
- j1 = row;
- j2 = col;
- pulse1 = GetMap()->GetSignalOnly(row,col);
- pulse2 = pulse1;
- for (Int_t isign=-1;isign<=1;isign+=2){// loop in row direction
- do{
- j1 += isign;
- // pulse1 *= couplR;
- xr = gRandom->Rndm();
- //if ((j1<0)||(j1>GetNPixelsZ()-1)||(pulse1<GetThreshold())){
- if ((j1<0) || (j1>GetNPixelsZ()-1) || (xr>couplR)){
- j1 = row;
- flag = 1;
- }else{
- UpdateMapSignal(col,j1,ntrack,idhit,pulse1);
- // flag = 0;
- flag = 1; // only first next!!
- } // end if
- } while(flag == 0);
- // loop in column direction
- do{
- j2 += isign;
- // pulse2 *= couplC;
- xr = gRandom->Rndm();
- //if((j2<0)||j2>(GetNPixelsX()-1)||pulse2<GetThreshold()){
- if ((j2<0) || (j2>GetNPixelsX()-1) || (xr>couplC)){
- j2 = col;
- flag = 1;
- }else{
- UpdateMapSignal(j2,row,ntrack,idhit,pulse2);
- // flag = 0;
- flag = 1; // only first next!!
- } // end if
- } while(flag == 0);
- } // for isign
-}
-//______________________________________________________________________
-void AliITSsimulationSPDdubna::SetCouplingOld(Int_t row, Int_t col,
- Int_t ntrack,Int_t idhit) {
- // Take into account the coupling between adiacent pixels.
- // The parameters probcol and probrow are the fractions of the
- // signal in one pixel shared in the two adjacent pixels along
- // the column and row direction, respectively.
- //Begin_Html
- /*
- <img src="picts/ITS/barimodel_3.gif">
- </pre>
- <br clear=left>
- <font size=+2 color=red>
- <a href="mailto:Rocco.Caliandro@ba.infn.it"></a>.
- </font>
- <pre>
- */
- //End_Html
- // Inputs:
- // Int_t row z cell index
- // Int_t col x cell index
- // Int_t ntrack track incex number
- // Int_t idhit hit index number
- // Int_t module module number
- // Outputs:
- // none.
- // Return:
- // none.
- Int_t j1,j2,flag=0;
- Double_t pulse1,pulse2;
- Double_t couplR=0.0,couplC=0.0;
-
- GetCouplings(couplR,couplC);
- if(GetDebug(3)) Info("SetCouplingOld","(row=%d,col=%d,ntrack=%d,idhit=%d) "
- "Calling SetCoupling couplR=%e couplC=%e",
- row,col,ntrack,idhit,couplR,couplC);
- j1 = row;
- j2 = col;
- pulse1 = GetMap()->GetSignalOnly(row,col);
- pulse2 = pulse1;
- for (Int_t isign=-1;isign<=1;isign+=2){// loop in row direction
- do{
- j1 += isign;
- pulse1 *= couplR;
- if ((j1<0)||(j1>GetNPixelsZ()-1)||(pulse1<GetThreshold())){
- pulse1 = GetMap()->GetSignalOnly(row,col);
- j1 = row;
- flag = 1;
- }else{
- UpdateMapSignal(col,j1,ntrack,idhit,pulse1);
- flag = 0;
- } // end if
- } while(flag == 0);
- // loop in column direction
- do{
- j2 += isign;
- pulse2 *= couplC;
- if((j2<0)||(j2>(GetNPixelsX()-1))||(pulse2<GetThreshold())){
- pulse2 = GetMap()->GetSignalOnly(row,col);
- j2 = col;
- flag = 1;
- }else{
- UpdateMapSignal(j2,row,ntrack,idhit,pulse2);
- flag = 0;
- } // end if
- } while(flag == 0);
- } // for isign
-}
+++ /dev/null
-#ifndef ALIITSSIMULATIONSPDDUBNA_H
-#define ALIITSSIMULATIONSPDDUBNA_H
-
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * See cxx source for full Copyright notice */
-
-#include "TH1F.h"
-#include "TObjArray.h"
-#include "AliITSsimulation.h"
-#include "AliITSCalibrationSPD.h"
-#include "AliITSsegmentationSPD.h"
-#include "AliITSresponseSPD.h"
-
-class AliITSmodule;
-
-//-------------------------------------------------------------------
-
-class AliITSsimulationSPDdubna : public AliITSsimulation {
- public:
- AliITSsimulationSPDdubna();
- // AliITSsimulationSPDdubna(AliITSsegmentation *seg,AliITSCalibration *res,
- // Int_t cup=1);
- AliITSsimulationSPDdubna(AliITSDetTypeSim *dettyp,Int_t cup=1);
- virtual ~AliITSsimulationSPDdubna();
- // copy constructor
- AliITSsimulationSPDdubna(const AliITSsimulationSPDdubna &source);
- // ass. operator
- AliITSsimulationSPDdubna& operator=(const AliITSsimulationSPDdubna &s);
- virtual AliITSsimulation& operator=(const AliITSsimulation &source);
- // Initilizes the variables
- void Init();
-
- // General User calling routines
- // Initilize simulation for a specific event and module
- void InitSimulationModule(Int_t module, Int_t event);
- // Finish and write S Digitization
- void FinishSDigitiseModule();
- // From hits to Digits, without creating SDigits
- void DigitiseModule(AliITSmodule *mod,Int_t,Int_t);
-
- // More or less Internal Routines
- // Create S Digits from specific module
- void SDigitiseModule(AliITSmodule *mod, Int_t mask, Int_t event);
- // Write S Digits to the tree of SDigits.
- void WriteSDigits();
- // fill pList from hits, charge sharing, diffusion, coupling
- void HitToSDigit(AliITSmodule *mod);
- // Take pList of signals and apply noise... create Digis
- void pListToDigits();
- //
- void CreateHistograms();
- void FillHistograms(Int_t ix,Int_t iz,Double_t v=1.0);
- void ResetHistograms();
- TH1F* GetHistogram(Int_t i){return (TH1F*)(fHis->At(i));}// get histogram
- TObjArray* GetHistArray() {return fHis;}// get hist array
- TString& GetHistName(){return fSPDname;}
- void SetHistName(TString &n){fSPDname = n;}
- //
- // For backwards compatibility
- void SDigitsToDigits(){ FinishSDigitiseModule();};
- void HitToDigit(AliITSmodule *mod){
- // Standard interface to DigitiseModule
- // Inputs:
- // AliITSmodule *mod Pointer to this module
- // Outputs:
- // none.
- // Return:
- // none.
- DigitiseModule(mod,GetModuleNumber(),0);};
-
- private:
- void SpreadCharge(Double_t x0,Double_t z0,Int_t ix0,Int_t iz0,
- Double_t el,Double_t sig,Int_t t,Int_t hi);
- void UpdateMapSignal(Int_t ix,Int_t iz,Int_t trk,Int_t ht,Double_t signal){
- // This function adds a signal to the pList from the pList class
- // Inputs:
- // Int_t iz // row number
- // Int_t ix // column number
- // Int_t trk // track number
- // Int_t ht // hit number
- // Double_t signal // signal strength
- // Outputs:
- // none.
- // Return:
- // none
- GetMap()->AddSignal(iz,ix,trk,ht,GetModuleNumber(),signal);};
- void UpdateMapNoise(Int_t ix,Int_t iz,Float_t noise){
- // This function adds noise to data in the MapA2 as well as the pList
- // Inputs:
- // Int_t iz // row number
- // Int_t ix // column number
- // Double_t ns // electronic noise generated by pListToDigits
- // Outputs:
- // none.
- // Return:
- // none
- GetMap()->AddNoise(iz,ix,GetModuleNumber(),noise);}
- // Get a pointer to the segmentation object
- virtual AliITSsegmentation* GetSegmentationModel(Int_t /*dt*/){return fDetType->GetSegmentationModel(0);}
- // set pointer to segmentation objec
- virtual void SetSegmentationModel(Int_t /*dt*/, AliITSsegmentation *seg){fDetType->SetSegmentationModel(0,seg);}
- // Bari-Salerno Coupling parameters
- // "New" coupling routine Tiziano Virgili
- void SetCoupling(Int_t row,Int_t col,Int_t ntrack,Int_t idhit);
- // "Old" coupling routine Rocco Caliandro
- void SetCouplingOld(Int_t row, Int_t col,Int_t ntrack,Int_t idhit);
- // Getters for data kept in fSegmentation and fResponse.
- // Returns the Threshold in electrons
- Double_t GetThreshold(){
- Double_t th,sig;AliITSCalibrationSPD* res=(AliITSCalibrationSPD*)GetCalibrationModel(GetModuleNumber());
- res->Thresholds(th,sig);return th;};
- // Returns the couplings Columb and Row.
- void GetCouplings(Double_t &cc,Double_t &cr){
- AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(GetModuleNumber());
- res->GetCouplingParam(cc,cr);};
- // Returns the number of pixels in x
- Int_t GetNPixelsX(){return GetSegmentationModel(0)->Npx();};
- // Returns the number of pixels in z
- Int_t GetNPixelsZ(){return GetSegmentationModel(0)->Npz();};
-
- TObjArray *fHis; //! just in case for histogramming
- TString fSPDname; //! Histogram name
- Int_t fCoupling; // Sets the coupling to be used.
- // ==1 use SetCoupling, ==2 use SetCouplingOld
- // with diffusion turned off (by constructor)
- // ==3 use SetCoupling, ==4 use SetCouplingOld
- // with diffusion, else no coupling.
- ClassDef(AliITSsimulationSPDdubna,3) // Simulation of SPD clusters
-};
-#endif
--- /dev/null
+/**************************************************************************
+ * 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. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+/* $Id$ */
+
+#include <TRandom.h>
+#include <TH1.h>
+#include <TString.h>
+
+#include "AliRun.h"
+#include "AliITS.h"
+#include "AliITSdigitSPD.h"
+#include "AliITSmodule.h"
+#include "AliITSMapA2.h"
+#include "AliITSpList.h"
+#include "AliITSsimulationSPD.h"
+#include "AliLog.h"
+
+//#define DEBUG
+
+ClassImp(AliITSsimulationSPD)
+////////////////////////////////////////////////////////////////////////
+// Version: 0
+// Written by Rocco Caliandro
+// from a model developed with T. Virgili and R.A. Fini
+// June 15 2000
+//
+// AliITSsimulationSPD is the simulation of SPDs
+//
+//______________________________________________________________________
+AliITSsimulationSPD::AliITSsimulationSPD() : AliITSsimulation(),
+fMapA2(0),
+fHis(0){
+ // Default constructor
+ // Inputs:
+ // none.
+ // Outputs:
+ // none.
+ // Return:
+ // A default constructed AliITSsimulationSPD class.
+}
+//______________________________________________________________________
+AliITSsimulationSPD::AliITSsimulationSPD(AliITSDetTypeSim *dettyp):
+AliITSsimulation(dettyp),
+fMapA2(0),
+fHis(0){
+ // Standard constructor
+ // Inputs:
+ // AliITSsegmentation *seg Segmentation class to be used
+ // AliITSresonse *res Response class to be used
+ // Outputs:
+ // none.
+ // Return:
+ // A standard constructed AliITSsimulationSPD class.
+
+ Init();
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::Init() {
+ // Initilizes the variables of AliITSsimulation SPD.
+ // Inputs:
+ // none.
+ // Outputs:
+ // none.
+ // Return:
+ // none.
+
+ fHis = 0;
+ if(fMapA2) delete fMapA2;
+ AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
+ fMapA2 = new AliITSMapA2(seg);
+ if(fpList) delete fpList;
+ fpList = new AliITSpList(GetNPixelsZ()+1,GetNPixelsX()+1);
+}
+/*
+//______________________________________________________________________
+void AliITSsimulationSPD::Init(AliITSsegmentationSPD *seg,
+ AliITSCalibrationSPD *resp) {
+ // Initilizes the variables of AliITSsimulation SPD.
+ // Inputs:
+ // AliITSsegmentationSPD replacement segmentation class to be used
+ // aliITSresponseSPD replacement response class to be used
+ // Outputs:
+ // none.
+ // Return:
+ // none.
+
+ if(fHis){
+ fHis->Delete();
+ delete fHis;
+ } // end if fHis
+ fHis = 0;
+ if(fResponse) delete fResponse;
+ fResponse = resp;
+ if(GetSegmentationModel(0)) delete GetSegmentationModel(0);
+ GetSegmentationModel(0) = seg;
+ if(fMapA2) delete fMapA2;
+ fMapA2 = new AliITSMapA2(GetSegmentationModel(0));
+ if(fpList) delete fpList;
+ fpList = new AliITSpList(GetNPixelsZ()+1,GetNPixelsX()+1);
+}
+*/
+//______________________________________________________________________
+AliITSsimulationSPD::~AliITSsimulationSPD() {
+ // destructor
+ // Inputs:
+ // none.
+ // Outputs:
+ // none.
+ // Return:
+ // none.
+
+ if(fMapA2) delete fMapA2;
+ if (fHis) {
+ fHis->Delete();
+ delete fHis;
+ } // end if
+}
+//______________________________________________________________________
+AliITSsimulationSPD::AliITSsimulationSPD(const AliITSsimulationSPD &source) :
+ AliITSsimulation(source){
+ // Copy Constructor
+ // Inputs:
+ // none.
+ // Outputs:
+ // none.
+ // Return:
+ // A new AliITSsimulationSPD class with the same parameters as source.
+
+ if(&source == this) return;
+
+ this->fMapA2 = source.fMapA2;
+ this->fHis = source.fHis;
+ return;
+}
+//______________________________________________________________________
+AliITSsimulationSPD& AliITSsimulationSPD::operator=(const AliITSsimulationSPD
+ &source) {
+ // Assignment operator
+ // Inputs:
+ // none.
+ // Outputs:
+ // none.
+ // Return:
+ // A new AliITSsimulationSPD class with the same parameters as source.
+
+ if(&source == this) return *this;
+
+ this->fMapA2 = source.fMapA2;
+ this->fHis = source.fHis;
+ return *this;
+}
+//______________________________________________________________________
+AliITSsimulation& AliITSsimulationSPD::operator=(const AliITSsimulation
+ &source) {
+ // Assignment operator
+ // Inputs:
+ // none.
+ // Outputs:
+ // none.
+ // Return:
+ // A new AliITSsimulationSPD class with the same parameters as source.
+
+ if(&source == this) return *this;
+ Error("AliITSsimulationSPD","Not allowed to make a = with "
+ "AliITSsimulationSPD Using default creater instead");
+
+ return *this;
+}
+
+//______________________________________________________________________
+void AliITSsimulationSPD::InitSimulationModule(Int_t module,Int_t event){
+ // Creates maps to build the list of tracks for each sumable digit
+ // Inputs:
+ // Int_t module // Module number to be simulated
+ // Int_t event // Event number to be simulated
+ // Outputs:
+ // none.
+ // Return
+ // none.
+
+ fModule = module;
+ fEvent = event;
+ fMapA2->ClearMap();
+ fpList->ClearMap();
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::FinishSDigitiseModule(){
+ // Does the Sdigits to Digits work
+ // Inputs:
+ // none.
+ // Outputs:
+ // none.
+ // Return:
+ // none.
+
+ SDigitsToDigits(fModule,fpList);
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::SDigitiseModule(AliITSmodule *mod, Int_t dummy0,
+ Int_t dummy1) {
+ // Sum digitize module
+ // Inputs:
+ // AliITSmodule *mod The module to be SDgitized
+ // Int_t dummy0 Not used kept for general compatibility
+ // Int_t dummy1 Not used kept for general compatibility
+ // Outputs:
+ // none.
+ // Return:
+ // none.
+ if (!(mod->GetNhits())) return; // if module has no hits then no Sdigits.
+ Int_t number = 10000;
+ Int_t *frowpixel = new Int_t[number];
+ Int_t *fcolpixel = new Int_t[number];
+ Double_t *fenepixel = new Double_t[number];
+
+ dummy0 = dummy1; // remove unsued variable warning.
+ fModule = mod->GetIndex();
+
+ // Array of pointers to store the track index of the digits
+ // leave +1, otherwise pList crashes when col=256, row=192
+
+ HitsToAnalogDigits(mod,frowpixel,fcolpixel,fenepixel,fpList);
+
+ WriteSDigits(fpList);
+
+ // clean memory
+ delete[] frowpixel;
+ delete[] fcolpixel;
+ delete[] fenepixel;
+ fMapA2->ClearMap();
+ fpList->ClearMap();
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::DigitiseModule(AliITSmodule *mod, Int_t,Int_t) {
+ // digitize module. Also need to digitize modules with only noise.
+ // Inputs:
+ // AliITSmodule *mod The module to be SDgitized
+ // Outputs:
+ // none.
+ // Return:
+ // none.
+
+ Int_t number = 10000;
+ Int_t *frowpixel = new Int_t[number];
+ Int_t *fcolpixel = new Int_t[number];
+ Double_t *fenepixel = new Double_t[number];
+
+ // Array of pointers to store the track index of the digits
+ // leave +1, otherwise pList crashes when col=256, row=192
+ fModule = mod->GetIndex();
+ // noise setting
+ SetFluctuations(fpList,fModule);
+
+ HitsToAnalogDigits(mod,frowpixel,fcolpixel,fenepixel,fpList);
+
+ // apply mask to SPD module
+ SetMask(fModule);
+
+ CreateDigit(fModule,fpList);
+
+ // clean memory
+ delete[] frowpixel;
+ delete[] fcolpixel;
+ delete[] fenepixel;
+ fMapA2->ClearMap();
+ fpList->ClearMap();
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::SDigitsToDigits(Int_t module,AliITSpList *pList) {
+ // sum digits to Digits.
+ // Inputs:
+ // AliITSmodule *mod The module to be SDgitized
+ // AliITSpList *pList the array of SDigits
+ // Outputs:
+ // AliITSpList *pList the array of SDigits
+ // Return:
+ // none.
+
+ AliDebug(1,Form("Entering AliITSsimulatinSPD::SDigitsToDigits for module=%d",
+ module));
+ fModule = module;
+
+ // noise setting
+ SetFluctuations(pList,module);
+
+ fMapA2->ClearMap(); // since noise is in pList aready. Zero Map so that
+ // noise is not doubled when calling FillMapFrompList.
+
+ FillMapFrompList(pList);
+
+ // apply mask to SPD module
+ SetMask(fModule);
+
+ CreateDigit(module,pList);
+
+ fMapA2->ClearMap();
+ pList->ClearMap();
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::UpdateMapSignal(Int_t row,Int_t col,Int_t trk,
+ Int_t hit,Int_t mod,Double_t ene,
+ AliITSpList *pList) {
+ // updates the Map of signal, adding the energy (ene) released by
+ // the current track
+ // Inputs:
+ // Int_t row pixel row number
+ // Int_t col pixel column number
+ // Int_t trk track number which contributed
+ // Int_t hit hit number which contributed
+ // Int_t mod module number
+ // Double_t ene the energy associated with this contribution
+ // AliITSpList *pList the array of SDigits
+ // Outputs:
+ // AliITSpList *pList the array of SDigits
+ // Return:
+ // none.
+
+ fMapA2->AddSignal(row,col,ene);
+ pList->AddSignal(row,col,trk,hit,mod,ene);
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::UpdateMapNoise(Int_t row,Int_t col,Int_t mod,
+ Double_t ene,AliITSpList *pList) {
+ // updates the Map of noise, adding the energy (ene) give my noise
+ // Inputs:
+ // Int_t row pixel row number
+ // Int_t col pixel column number
+ // Int_t mod module number
+ // Double_t ene the energy associated with this contribution
+ // AliITSpList *pList the array of SDigits
+ // Outputs:
+ // AliITSpList *pList the array of SDigits
+ // Return:
+ // none.
+
+ fMapA2->AddSignal(row,col,ene);
+ pList->AddNoise(row,col,mod,ene);
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::HitsToAnalogDigits(AliITSmodule *mod,
+ Int_t *frowpixel,Int_t *fcolpixel,
+ Double_t *fenepixel,
+ AliITSpList *pList) {
+ // Loops over all hits to produce Analog/floting point digits. This
+ // is also the first task in producing standard digits.
+ // Inputs:
+ // AliITSmodule *mod module class
+ // Int_t *frowpixel array of pixel rows
+ // Int_t *fcolpixel array of pixel columns
+ // Double_t *fenepiexel array of pixel energies
+ // AliITSpList *pList the array of SDigits
+ // Outputs:
+ // AliITSpList *pList the array of SDigits
+ // Return:
+ // none.
+
+ // loop over hits in the module
+ Int_t hitpos,nhits = mod->GetNhits();
+ for (hitpos=0;hitpos<nhits;hitpos++) {
+ HitToDigit(mod,hitpos,frowpixel,fcolpixel,fenepixel,pList);
+ }// end loop over digits
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::HitToDigit(AliITSmodule *mod,Int_t hitpos,
+ Int_t *frowpixel,Int_t *fcolpixel,
+ Double_t *fenepixel,AliITSpList *pList) {
+ // Steering function to determine the digits associated to a given
+ // hit (hitpos)
+ // The digits are created by charge sharing (ChargeSharing) and by
+ // capacitive coupling (SetCoupling). At all the created digits is
+ // associated the track number of the hit (ntrack)
+ // Inputs:
+ // AliITSmodule *mod module class
+ // Int_t hitpos hit index value
+ // Int_t *frowpixel array of pixel rows
+ // Int_t *fcolpixel array of pixel columns
+ // Double_t *fenepiexel array of pixel energies
+ // AliITSpList *pList the array of SDigits
+ // Outputs:
+ // AliITSpList *pList the array of SDigits
+ // Return:
+ // none.
+ Double_t x1l=0.0,y1l=0.0,z1l=0.0,x2l=0.0,y2l=0.0,z2l=0.0;
+ Int_t r1,r2,c1,c2,row,col,npixel = 0;
+ Int_t ntrack;
+ Double_t ene=0.0,etot=0.0;
+ const Float_t kconv = 10000.; // cm -> microns
+ const Float_t kconv1= 0.277e9; // GeV -> electrons equivalent
+
+ if(!(mod->LineSegmentL(hitpos,x1l,x2l,y1l,y2l,z1l,z2l,etot,ntrack)))return;
+
+ x2l += x1l; y2l += y1l; z2l += z1l; // Convert to ending coordinate.
+ // positions shifted and converted in microns
+ x1l = x1l*kconv + GetSegmentationModel(0)->Dx()/2.;
+ z1l = z1l*kconv + GetSegmentationModel(0)->Dz()/2.;
+ // positions shifted and converted in microns
+ x2l = x2l*kconv + GetSegmentationModel(0)->Dx()/2.;
+ z2l = z2l*kconv + GetSegmentationModel(0)->Dz()/2.;
+ etot *= kconv1; // convert from GeV to electrons equivalent.
+ Int_t module = mod->GetIndex();
+
+ // to account for the effective sensitive area
+ // introduced in geometry
+ if (z1l<0 || z1l>GetSegmentationModel(0)->Dz()) return;
+ if (z2l<0 || z2l>GetSegmentationModel(0)->Dz()) return;
+ if (x1l<0 || x1l>GetSegmentationModel(0)->Dx()) return;
+ if (x2l<0 || x2l>GetSegmentationModel(0)->Dx()) return;
+
+ //Get the col and row number starting from 1
+ // the x direction is not inverted for the second layer!!!
+ GetSegmentationModel(0)->GetPadIxz(x1l, z1l, c1, r1);
+ GetSegmentationModel(0)->GetPadIxz(x2l, z2l, c2, r2);
+
+ // to account for unexpected equal entrance and
+ // exit coordinates
+ if (x1l==x2l) x2l=x2l+x2l*0.1;
+ if (z1l==z2l) z2l=z2l+z2l*0.1;
+
+ if ((r1==r2) && (c1==c2)){
+ // no charge sharing
+ npixel = 1;
+ frowpixel[npixel-1] = r1;
+ fcolpixel[npixel-1] = c1;
+ fenepixel[npixel-1] = etot;
+ } else {
+ // charge sharing
+ ChargeSharing(x1l,z1l,x2l,z2l,c1,r1,c2,r2,etot,
+ npixel,frowpixel,fcolpixel,fenepixel);
+ } // end if r1==r2 && c1==c2.
+
+ for (Int_t npix=0;npix<npixel;npix++){
+ row = frowpixel[npix];
+ col = fcolpixel[npix];
+ ene = fenepixel[npix];
+ UpdateMapSignal(row,col,ntrack,hitpos,module,ene,pList);
+ // Starting capacitive coupling effect
+ SetCoupling(row,col,ntrack,hitpos,module,pList);
+ } // end for npix
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::ChargeSharing(Float_t x1l,Float_t z1l,Float_t x2l,
+ Float_t z2l,Int_t c1,Int_t r1,Int_t c2,
+ Int_t r2,Float_t etot,
+ Int_t &npixel,Int_t *frowpixel,
+ Int_t *fcolpixel,Double_t *fenepixel){
+ // Take into account the geometrical charge sharing when the track
+ // crosses more than one pixel.
+ // Inputs:
+ // Float_t x1l
+ // Float_t z1l
+ // Float_t x2l
+ // Float_t z2l
+ // Int_t c1
+ // Int_t r1
+ // Int_t c2
+ // Int_t r2
+ // Float_t etot
+ // Int_t &npixel
+ // Int_t *frowpixel array of pixel rows
+ // Int_t *fcolpixel array of pixel columns
+ // Double_t *fenepiexel array of pixel energies
+ // Outputs:
+ // Int_t &npixel
+ // Return:
+ // none.
+ //
+ //Begin_Html
+ /*
+ <img src="picts/ITS/barimodel_2.gif">
+ </pre>
+ <br clear=left>
+ <font size=+2 color=red>
+ <a href="mailto:Rocco.Caliandro@ba.infn.it"></a>.
+ </font>
+ <pre>
+ */
+ //End_Html
+ //Float_t dm;
+ Float_t xa,za,xb,zb,dx,dz,dtot,refr,refm,refc;
+ Float_t refn=0.;
+ Float_t arefm, arefr, arefn, arefc, azb, az2l, axb, ax2l;
+ Int_t dirx,dirz,rb,cb;
+ Int_t flag,flagrow,flagcol;
+ Double_t epar;
+
+ npixel = 0;
+ xa = x1l;
+ za = z1l;
+// dx = x1l-x2l;
+// dz = z1l-z2l;
+ dx = x2l-x1l;
+ dz = z2l-z1l;
+ dtot = TMath::Sqrt((dx*dx)+(dz*dz));
+ if (dtot==0.0) dtot = 0.01;
+ dirx = (Int_t) TMath::Sign((Float_t)1,dx);
+ dirz = (Int_t) TMath::Sign((Float_t)1,dz);
+
+ // calculate the x coordinate of the pixel in the next column
+ // and the z coordinate of the pixel in the next row
+ Float_t xpos, zpos;
+
+ GetSegmentationModel(0)->GetPadCxz(c1, r1-1, xpos, zpos);
+
+ Float_t xsize = GetSegmentationModel(0)->Dpx(0);
+ Float_t zsize = GetSegmentationModel(0)->Dpz(r1-1);
+
+ if (dirx == 1) refr = xpos+xsize/2.;
+ else refr = xpos-xsize/2.;
+
+ if (dirz == 1) refn = zpos+zsize/2.;
+ else refn = zpos-zsize/2.;
+
+ flag = 0;
+ flagrow = 0;
+ flagcol = 0;
+ do{
+ // calculate the x coordinate of the intersection with the pixel
+ // in the next cell in row direction
+ if(dz!=0)
+ refm = dx*((refn - z1l)/dz) + x1l;
+ else
+ refm = refr+dirx*xsize;
+
+ // calculate the z coordinate of the intersection with the pixel
+ // in the next cell in column direction
+ if (dx!=0)
+ refc = dz*((refr - x1l)/dx) + z1l;
+ else
+ refc = refn+dirz*zsize;
+
+ arefm = refm * dirx;
+ arefr = refr * dirx;
+ arefn = refn * dirz;
+ arefc = refc * dirz;
+
+ if ((arefm < arefr) && (arefn < arefc)){
+ // the track goes in the pixel in the next cell in row direction
+ xb = refm;
+ zb = refn;
+ cb = c1;
+ rb = r1 + dirz;
+ azb = zb * dirz;
+ az2l = z2l * dirz;
+ if (rb == r2) flagrow=1;
+ if (azb > az2l) {
+ zb = z2l;
+ xb = x2l;
+ } // end if
+ // shift to the pixel in the next cell in row direction
+ Float_t zsizeNext = GetSegmentationModel(0)->Dpz(rb-1);
+ //to account for cell at the borders of the detector
+ if(zsizeNext==0) zsizeNext = zsize;
+ refn += zsizeNext*dirz;
+ }else {
+ // the track goes in the pixel in the next cell in column direction
+ xb = refr;
+ zb = refc;
+ cb = c1 + dirx;
+ rb = r1;
+ axb = xb * dirx;
+ ax2l = x2l * dirx;
+ if (cb == c2) flagcol=1;
+ if (axb > ax2l) {
+ zb = z2l;
+ xb = x2l;
+ } // end ifaxb > ax2l
+
+ // shift to the pixel in the next cell in column direction
+ Float_t xsizeNext = GetSegmentationModel(0)->Dpx(cb-1);
+ //to account for cell at the borders of the detector
+ if(xsizeNext==0) xsizeNext = xsize;
+ refr += xsizeNext*dirx;
+ } // end if (arefm < arefr) && (arefn < arefc)
+
+ //calculate the energy lost in the crossed pixel
+ epar = TMath::Sqrt((xb-xa)*(xb-xa)+(zb-za)*(zb-za));
+ epar = etot*(epar/dtot);
+
+ //store row, column and energy lost in the crossed pixel
+ frowpixel[npixel] = r1;
+ fcolpixel[npixel] = c1;
+ fenepixel[npixel] = epar;
+ npixel++;
+
+ // the exit point of the track is reached
+ if (epar == 0) flag = 1;
+ if ((r1 == r2) && (c1 == c2)) flag = 1;
+ if (flag!=1) {
+ r1 = rb;
+ c1 = cb;
+ xa = xb;
+ za = zb;
+ } // end if flag!=1
+ } while (flag==0);
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::SetCoupling(Int_t row, Int_t col, Int_t ntrack,
+ Int_t idhit,Int_t module,
+ AliITSpList *pList) {
+ // Take into account the coupling between adiacent pixels.
+ // The parameters probcol and probrow are the probability of the
+ // signal in one pixel shared in the two adjacent pixels along
+ // the column and row direction, respectively.
+ // Inputs:
+ // Int_t row pixel row number
+ // Int_t col pixel column number
+ // Int_t ntrack track number of track contributing to this signal
+ // Int_t idhit hit number of hit contributing to this signal
+ // Int_t module module number
+ // AliITSpList *pList the array of SDigits
+ // Outputs:
+ // AliITSpList *pList the array of SDigits
+ // Return:
+ // none.
+ //
+ //Begin_Html
+ /*
+ <img src="picts/ITS/barimodel_3.gif">
+ </pre>
+ <br clear=left>
+ <font size=+2 color=red>
+ <a href="mailto:tiziano.virgili@cern.ch"></a>.
+ </font>
+ <pre>
+ */
+ //End_Html
+ Int_t j1,j2,flag=0;
+ Double_t pulse1,pulse2;
+ Double_t couplR=0.0,couplC=0.0;
+ Double_t xr=0.;
+
+ GetCouplings(couplR,couplC);
+ j1 = row;
+ j2 = col;
+ pulse1 = fMapA2->GetSignal(row,col);
+ pulse2 = pulse1;
+ for (Int_t isign=-1;isign<=1;isign+=2){// loop in row direction
+ do{
+ j1 += isign;
+ // pulse1 *= couplR;
+ xr = gRandom->Rndm();
+ //if ((j1<0) || (j1>GetNPixelsZ()-1) || (pulse1<GetThreshold())){
+ if ((j1<0) || (j1>GetNPixelsZ()-1) || (xr>couplR)){
+ j1 = row;
+ flag = 1;
+ }else{
+ UpdateMapSignal(j1,col,ntrack,idhit,module,pulse1,pList);
+ // flag = 0;
+ flag = 1; // only first next!!
+ } // end if
+ } while(flag == 0);
+ // loop in column direction
+ do{
+ j2 += isign;
+ // pulse2 *= couplC;
+ xr = gRandom->Rndm();
+ //if ((j2<0) || (j2>(GetNPixelsX()-1)) || (pulse2<GetThreshold())){
+ if ((j2<0) || (j2>GetNPixelsX()-1) || (xr>couplC)){
+ j2 = col;
+ flag = 1;
+ }else{
+ UpdateMapSignal(row,j2,ntrack,idhit,module,pulse2,pList);
+ // flag = 0;
+ flag = 1; // only first next!!
+ } // end if
+ } while(flag == 0);
+ } // for isign
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::SetCouplingOld(Int_t row, Int_t col, Int_t ntrack,
+ Int_t idhit,Int_t module,
+ AliITSpList *pList) {
+ // Take into account the coupling between adiacent pixels.
+ // The parameters probcol and probrow are the fractions of the
+ // signal in one pixel shared in the two adjacent pixels along
+ // the column and row direction, respectively.
+ // Inputs:
+ // Int_t row pixel row number
+ // Int_t col pixel column number
+ // Int_t ntrack track number of track contributing to this pixel
+ // Int_t idhit hit index number of hit contributing to this pixel
+ // Int_t module module number
+ // AliITSpList *pList the array of SDigits
+ // Outputs:
+ // AliITSpList *pList the array of SDigits
+ // Return:
+ // none.
+ //
+ //Begin_Html
+ /*
+ <img src="picts/ITS/barimodel_3.gif">
+ </pre>
+ <br clear=left>
+ <font size=+2 color=red>
+ <a href="mailto:Rocco.Caliandro@ba.infn.it"></a>.
+ </font>
+ <pre>
+ */
+ //End_Html
+ Int_t j1,j2,flag=0;
+ Double_t pulse1,pulse2;
+ Double_t couplR=0.0,couplC=0.0;
+
+ GetCouplings(couplR,couplC);
+ j1 = row;
+ j2 = col;
+ pulse1 = fMapA2->GetSignal(row,col);
+ pulse2 = pulse1;
+ for (Int_t isign=-1;isign<=1;isign+=2){// loop in row direction
+ do{
+ j1 += isign;
+ pulse1 *= couplR;
+ if ((j1<0) || (j1>GetNPixelsZ()-1) || (pulse1<GetThreshold())){
+ pulse1 = fMapA2->GetSignal(row,col);
+ j1 = row;
+ flag = 1;
+ }else{
+ UpdateMapSignal(j1,col,ntrack,idhit,module,pulse1,pList);
+ flag = 0;
+ } // end if
+ } while(flag == 0);
+ // loop in column direction
+ do{
+ j2 += isign;
+ pulse2 *= couplC;
+ if ((j2<0) || (j2>(GetNPixelsX()-1)) || (pulse2<GetThreshold())){
+ pulse2 = fMapA2->GetSignal(row,col);
+ j2 = col;
+ flag = 1;
+ }else{
+ UpdateMapSignal(row,j2,ntrack,idhit,module,pulse2,pList);
+ flag = 0;
+ } // end if
+ } while(flag == 0);
+ } // for isign
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::CreateDigit(Int_t module,AliITSpList *pList) {
+ // The pixels are fired if the energy deposited inside them is above
+ // the threshold parameter ethr. Fired pixed are interpreted as digits
+ // and stored in the file digitfilename. One also needs to write out
+ // cases when there is only noise (nhits==0).
+ // Inputs:
+ // Int_t module
+ // AliITSpList *pList the array of SDigits
+ // Outputs:
+ // AliITSpList *pList the array of SDigits
+ // Return:
+ // none.
+
+ static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
+
+ Int_t size = AliITSdigitSPD::GetNTracks();
+ Int_t * digits = new Int_t[size];
+ Int_t * tracks = new Int_t[size];
+ Int_t * hits = new Int_t[size];
+ Float_t * charges = new Float_t[size];
+ Int_t j1;
+
+ module=0; // remove unused variable warning.
+ for(j1=0;j1<size;j1++){tracks[j1]=-3;hits[j1]=-1;charges[j1]=0.0;}
+ for (Int_t r=1;r<=GetNPixelsZ();r++) {
+ for (Int_t c=1;c<=GetNPixelsX();c++) {
+ // check if the deposited energy in a pixel is above the
+ // threshold
+ Float_t signal = (Float_t) fMapA2->GetSignal(r,c);
+ if ( signal > GetThreshold()) {
+ digits[0] = r-1; // digits starts from 0
+ digits[1] = c-1; // digits starts from 0
+ //digits[2] = 1;
+ digits[2] = (Int_t) signal; // the signal is stored in
+ // electrons
+ for(j1=0;j1<size;j1++){
+ if(j1<pList->GetNEntries()){
+ tracks[j1] = pList->GetTrack(r,c,j1);
+ hits[j1] = pList->GetHit(r,c,j1);
+ //}else{
+ //tracks[j1] = -3;
+ //hits[j1] = -1;
+ } // end if
+ //charges[j1] = 0;
+ } // end for j1
+ Float_t phys = 0;
+ aliITS->AddSimDigit(0,phys,digits,tracks,hits,charges);
+ AliDebug(1,Form("mod=%d r,c=%d,%d sig=%f noise=%f Msig=%d Thres=%f",
+ fModule,r,c,fpList->GetSignalOnly(r,c),fpList->GetNoise(r,c),
+ signal,GetThreshold()));
+ } // end if of threshold condition
+ } // for c
+ }// end do on pixels
+ delete [] digits;
+ delete [] tracks;
+ delete [] hits;
+ delete [] charges;
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::SetFluctuations(AliITSpList *pList,Int_t module) {
+ // Set the electronic noise and threshold non-uniformities to all the
+ // pixels in a detector.
+ // The parameter fSigma is the squared sum of the sigma due to noise
+ // and the sigma of the threshold distribution among pixels.
+ // Inputs:
+ // Int_t module modulel number
+ // AliITSpList *pList the array of SDigits
+ // Outputs:
+ // AliITSpList *pList the array of SDigits
+ // Return:
+ // none.
+ //
+ //Begin_Html
+ /*
+ <img src="picts/ITS/barimodel_1.gif">
+ </pre>
+ <br clear=left>
+ <font size=+2 color=red>
+ <a href="mailto:Rocco.Caliandro@ba.infn.it"></a>.
+ </font>
+ <pre>
+ */
+ //End_Html
+ Double_t thr=0.0,sigm=0.0;
+ Double_t signal,sigma;
+ Int_t iz,ix;
+
+ GetThresholds(thr,sigm);
+ sigma = (Double_t) sigm;
+ for(iz=1;iz<=GetNPixelsZ();iz++){
+ for(ix=1;ix<=GetNPixelsX();ix++){
+ signal = sigma*gRandom->Gaus();
+ fMapA2->SetHit(iz,ix,signal);
+ // insert in the label-signal-hit list the pixels fired
+ // only by noise
+ pList->AddNoise(iz,ix,module,signal);
+ } // end of loop on pixels
+ } // end of loop on pixels
+}
+
+
+
+//______________________________________________________________________
+void AliITSsimulationSPD::SetMask(Int_t mod) {
+ // Apply a mask to the SPD module. 1% of the pixel channels are
+ // masked. When the database will be ready, the masked pixels
+ // should be read from it.
+ // Inputs:
+ // none.
+ // Outputs:
+ // none.
+ // Return:
+ // none.
+ Double_t signal;
+ Int_t iz,ix,im;
+ Float_t totMask;
+ Float_t perc = ((AliITSCalibrationSPD*)GetCalibrationModel(mod))->GetFractionDead();
+ // in this way we get the same set of random numbers for all runs.
+ // This is a cluge for now.
+ static TRandom *rnd = new TRandom();
+
+ totMask= perc*GetNPixelsZ()*GetNPixelsX();
+ for(im=1;im<totMask;im++){
+ do{
+ ix=(Int_t)(rnd->Rndm()*(GetNPixelsX()-1.) + 1.);
+ } while(ix<=0 || ix>GetNPixelsX());
+ do{
+ iz=(Int_t)(rnd->Rndm()*(GetNPixelsZ()-1.) + 1.);
+ } while(iz<=0 || iz>GetNPixelsZ());
+ signal = -1.;
+ fMapA2->SetHit(iz,ix,signal);
+ } // end loop on masked pixels
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::CreateHistograms() {
+ // Create Histograms
+ // Inputs:
+ // none.
+ // Outputs:
+ // none.
+ // Return:
+ // none.
+ Int_t i;
+
+ fHis=new TObjArray(GetNPixelsZ());
+ for(i=0;i<GetNPixelsZ();i++) {
+ TString spdname("spd_");
+ Char_t candnum[4];
+ sprintf(candnum,"%d",i+1);
+ spdname.Append(candnum);
+ (*fHis)[i] = new TH1F(spdname.Data(),"SPD maps",
+ GetNPixelsX(),0.,(Float_t) GetNPixelsX());
+ } // end for i
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::ResetHistograms() {
+ // Reset histograms for this detector
+ // Inputs:
+ // none.
+ // Outputs:
+ // none.
+ // Return:
+ // none.
+ Int_t i;
+
+ for(i=0;i<GetNPixelsZ();i++ ) {
+ if ((*fHis)[i]) ((TH1F*)(*fHis)[i])->Reset();
+ } // end for i
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::WriteSDigits(AliITSpList *pList){
+ // Fills the Summable digits Tree
+ // Inputs:
+ // AliITSpList *pList the array of SDigits
+ // Outputs:
+ // AliITSpList *pList the array of SDigits
+ // Return:
+ // none.
+ Int_t i,ni,j,nj;
+ static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
+
+ pList->GetMaxMapIndex(ni,nj);
+ for(i=0;i<ni;i++)for(j=0;j<nj;j++){
+ if(pList->GetSignalOnly(i,j)>0.0){
+ aliITS->AddSumDigit(*(pList->GetpListItem(i,j)));
+ if(AliDebugLevel()>0){
+ cout << "pListSPD: " << *(pList->GetpListItem(i,j)) << endl;
+ AliDebug(1,Form("mod=%d r,c=%d %d sig=%f noise=%f",
+ fModule,i,j,fpList->GetSignalOnly(i,j),fpList->GetNoise(i,j)))
+ } // end if GetDebug
+ } // end if
+ } // end for i,j
+ return;
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::FillMapFrompList(AliITSpList *pList){
+ // Fills fMap2A from the pList of Summable digits
+ // Inputs:
+ // AliITSpList *pList the array of SDigits
+ // Outputs:
+ // AliITSpList *pList the array of SDigits
+ // Return:
+ // none.
+ Int_t ix,iz;
+
+ for(iz=0;iz<GetNPixelsZ();iz++)for(ix=0;ix<GetNPixelsX();ix++)
+ fMapA2->AddSignal(iz,ix,pList->GetSignal(iz,ix));
+ return;
+}
--- /dev/null
+#ifndef ALIITSSIMULATIONSPD_H
+#define ALIITSSIMULATIONSPD_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/*
+$Id$
+*/
+////////////////////////////////////////////////////////////////////////
+// Version: 0 //
+// Written by Rocco Caliandro //
+// from a model developed with T. Virgili and R.A. Fini //
+// June 15 2000 //
+// //
+// AliITSsimulationSPD is the simulation of SPDs //
+////////////////////////////////////////////////////////////////////////
+
+#include "AliITSCalibrationSPD.h"
+#include "AliITSsegmentationSPD.h"
+#include "AliITSsimulation.h"
+#include "AliITSresponseSPD.h"
+
+class AliITSMapA2;
+class AliITSpList;
+class AliITSmodule;
+
+//-------------------------------------------------------------------
+
+class AliITSsimulationSPD : public AliITSsimulation {
+
+ public:
+ AliITSsimulationSPD(); // Default constructor
+ // Standard constructor
+ AliITSsimulationSPD(AliITSDetTypeSim *dettyp);
+ virtual ~AliITSsimulationSPD();// destructor
+ AliITSsimulationSPD(const AliITSsimulationSPD &source); // copy constructo
+ // assignment operator
+ AliITSsimulationSPD& operator=(const AliITSsimulationSPD &source);
+ virtual AliITSsimulation& operator=(const AliITSsimulation &source);
+ // Get a pointer to the segmentation object
+ virtual AliITSsegmentation* GetSegmentationModel(Int_t /*dt*/){return fDetType->GetSegmentationModel(0);}
+ // set pointer to segmentation objec
+ virtual void SetSegmentationModel(Int_t /*dt*/, AliITSsegmentation *seg){fDetType->SetSegmentationModel(0,seg);}
+ // Initilizes the variables
+ void Init();
+ // Initilizes the variables with replacement segmentation/response class
+ // void Init(AliITSsegmentationSPD *seg, AliITSCalibrationSPD *resp);
+
+ // Sum digitize module
+ // Create maps to build the lists of tracks for each summable digit
+ void InitSimulationModule(Int_t module,Int_t events);
+ // Digitize module from the sum of summable digits.
+ void FinishSDigitiseModule();
+ void SDigitiseModule(AliITSmodule *mod, Int_t dummy0,Int_t dummy1);
+ // digitize module. Also need to digitize modules with only noise.
+ void DigitiseModule(AliITSmodule *mod,Int_t dummy0, Int_t dummy1);
+ // sum digits to Digits.
+ void SDigitsToDigits(Int_t module,AliITSpList *pList);
+ // updates the Map of signal, adding the energy (ene) released by
+ // the current track
+ void UpdateMapSignal(Int_t row,Int_t col,Int_t trk,Int_t hit,Int_t mod,
+ Double_t ene,AliITSpList *pList);
+ // updates the Map of noise, adding the energy (ene) give my noise
+ void UpdateMapNoise(Int_t row,Int_t col,Int_t mod,Double_t ene,
+ AliITSpList *pList);
+ // Loops over all hits to produce Analog/floting point digits. This
+ // is also the first task in producing standard digits.
+ void HitsToAnalogDigits(AliITSmodule *mod,Int_t *frowpixel,
+ Int_t *fcolpixel,Double_t *fenepixel,
+ AliITSpList *pList);
+ // Steering function to determine the digits associated to a given
+ // hit (hitpos)
+ // The digits are created by charge sharing (ChargeSharing) and by
+ // capacitive coupling (SetCoupling). At all the created digits is
+ // associated the track number of the hit (ntrack)
+ void HitToDigit(AliITSmodule *mod, Int_t hitpos,Int_t *frowpixel,
+ Int_t *fcolpixel, Double_t *fenepixel,AliITSpList *pList);
+ // Take into account the geometrical charge sharing when the track
+ // crosses more than one pixel.
+ void ChargeSharing(Float_t x1l,Float_t z1l,Float_t x2l,Float_t z2l,
+ Int_t c1,Int_t r1,Int_t c2,Int_t r2,Float_t etot,
+ Int_t &npixel,Int_t *frowpixel,Int_t *fcolpixel,
+ Double_t *fenepixel);
+ // Take into account the coupling between adiacent pixels.
+ // The parameters probcol and probrow are the fractions of the
+ // signal in one pixel shared in the two adjacent pixels along
+ // the column and row direction, respectively. Now done in a statistical
+ // way and not "mechanical" as in the Old version.
+ void SetCoupling(Int_t row,Int_t col,Int_t ntrack,Int_t idhit,Int_t module,
+ AliITSpList *pList);
+ // Take into account the coupling between adiacent pixels.
+ // The parameters probcol and probrow are the fractions of the
+ // signal in one pixel shared in the two adjacent pixels along
+ // the column and row direction, respectively.
+ void SetCouplingOld(Int_t row,Int_t col,Int_t ntrack,Int_t idhit,
+ Int_t module,AliITSpList *pList);
+ // The pixels are fired if the energy deposited inside them is above
+ // the threshold parameter ethr. Fired pixed are interpreted as digits
+ // and stored in the file digitfilename. One also needs to write out
+ // cases when there is only noise (nhits==0).
+ void CreateDigit(Int_t module,AliITSpList *pList);
+ // Set the electronic noise and threshold non-uniformities to all the
+ // pixels in a detector.
+ // The parameter fSigma is the squared sum of the sigma due to noise
+ // and the sigma of the threshold distribution among pixels.
+ void SetFluctuations(AliITSpList *pList,Int_t module);
+ // Apply a mask to the SPD module. 1% of the pixel channels are
+ // masked. When the database will be ready, the masked pixels
+ // should be read from it.
+ void SetMask(Int_t mod);
+ // Create Histograms
+ void CreateHistograms();
+ // Reset histograms for this detector
+ void ResetHistograms();
+ // Fills the Summable digits Tree
+ void WriteSDigits(AliITSpList *pList);
+ // Fills fMap2A from the pList of Summable digits
+ void FillMapFrompList(AliITSpList *pList);
+ // get hist array
+ TObjArray* GetHistArray() {return fHis;}
+
+ private:
+ // Getters for data kept in fSegmentation and fResponse.
+ // Returns the Threshold in electrons
+ Double_t GetThreshold(){Double_t a=0.0,b=0.0;
+ AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(GetModuleNumber());
+ res->Thresholds(a,b); return a;}
+ // Returns the threshold and rms noise.
+ void GetThresholds(Double_t &t,Double_t &s){
+ AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(GetModuleNumber());
+ res->Thresholds(t,s);}
+ // Returns the couplings Columb and Row.
+ void GetCouplings(Double_t &cc,Double_t &cr){
+ AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(GetModuleNumber());
+ res->GetCouplingParam(cc,cr);}
+ // Returns the number of pixels in x
+ Int_t GetNPixelsX(){AliITSsegmentationSPD* seg= (AliITSsegmentationSPD*)GetSegmentationModel(0);return seg->Npx();}
+ // Returns the number of pixels in z
+ Int_t GetNPixelsZ(){AliITSsegmentationSPD* seg= (AliITSsegmentationSPD*)GetSegmentationModel(0);return seg->Npz();}
+
+ private:
+ AliITSMapA2 *fMapA2; //! MapA2 for Local internal use only
+ TObjArray *fHis; //! just in case for histogramming for Local
+ // internal use only
+
+ ClassDef(AliITSsimulationSPD,1) // Simulation of SPD clusters
+
+};
+
+#endif
#include "AliITSsegmentationSPD.h"
#include "AliITSsegmentationSDD.h"
#include "AliITSsegmentationSSD.h"
-#include "AliITSsimulationSPDdubna.h"
+#include "AliITSsimulationSPD.h"
#include "AliITSsimulationSDD.h"
#include "AliITSsimulationSSD.h"
//if(seg==0) seg = new AliITSsegmentationSPD();
//res = (AliITSCalibration*)fDetTypeSim->GetResponseModel(GetITSgeom()->GetStartSPD());
//if(res==0) res = new AliITSCalibrationSPD();
- sim = new AliITSsimulationSPDdubna(fDetTypeSim);
+ sim = new AliITSsimulationSPD(fDetTypeSim);
SetSimulationModel(kSPD,sim);
}else{ // simulation exists, make sure it is set up properly.
sim->SetSegmentationModel(kSPD,(AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSPD));
#include "AliITSDetTypeSim.h"
#include "AliITSCalibrationSPD.h"
#include "AliITSsegmentationSPD.h"
-#include "AliITSsimulationSPDdubna.h"
+#include "AliITSsimulationSPD.h"
#include "AliMC.h"
if (!sim) {
//seg = (AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSPD);
//res = (AliITSCalibration*)fDetTypeSim->GetResponseModel(GetITSgeom()->GetStartSPD());
- sim = new AliITSsimulationSPDdubna(fDetTypeSim);
+ sim = new AliITSsimulationSPD(fDetTypeSim);
SetSimulationModel(kSPD,sim);
}else{ // simulation exists, make sure it is set up properly.
sim->SetCalibrationModel(GetITSgeom()->GetStartSPD(),(AliITSCalibration*)fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSPD()));
#pragma link C++ class AliITSmodule+;
#pragma link C++ class AliITSsimulation+;
#pragma link C++ class AliITSsimulationSPD+;
-#pragma link C++ class AliITSsimulationSPDdubna+;
#pragma link C++ class AliITSsimulationSDD+;
#pragma link C++ class AliITSsimulationSSD+;
#pragma link C++ class AliITSTableSSD+;
AliITSsimulationFastPointsV0.cxx \
AliITSsimulation.cxx \
AliITSsimulationSPD.cxx \
- AliITSsimulationSPDdubna.cxx \
AliITSsimulationSDD.cxx \
AliITSsimulationSSD.cxx \
AliITSTableSSD.cxx \