ROOT logo
#ifndef ALIITSDETTYPESIM_H
#define ALIITSDETTYPESIM_H
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

/*
$Id$ 
*/

/////////////////////////////////////////////////////////////////////////
// * This class contains all of the "external" information needed to do//
// * detector specific simulations for the ITS.                        //
/////////////////////////////////////////////////////////////////////////

#include <TObject.h>
#include "AliITSLoader.h"
#include "AliITSSimuParam.h"
#include "AliITSFOGeneratorSPD.h"

class TObjArray;
class TClonesArray;
class TTree;
class AliCDBMetaData;
class AliITSdigit;
class AliITSmodule;
class AliITSpListItem;
class AliITSsimulation;
class AliITSsegmentation;
class AliITSresponse;
class AliITSCalibrationSSD;
class AliITSGainSSDv2;
class AliITSBadChannelsSSDv2;
class AliITSNoiseSSDv2;
class AliITSresponseSDD;
class AliITSDDLModuleMapSDD;
class AliITSCalibration;
class AliITSgeom;
class AliITSFOSignalsSPD;
class AliITSTriggerConditions;

class AliITSDetTypeSim : public TObject {
 public:
  
    AliITSDetTypeSim();
    virtual ~AliITSDetTypeSim(); 
    AliITSgeom *GetITSgeom() const {
        if(fLoader)return ((AliITSLoader*)fLoader)->GetITSgeom();
	else return 0;}
    void SetITSgeom(AliITSgeom *geom);
    
    virtual void SetSimulationModel(Int_t dettype,AliITSsimulation *sim);
    virtual AliITSsimulation* GetSimulationModel(Int_t dettype) const;        
    virtual AliITSsimulation* GetSimulationModelByModule(Int_t module) const;
        
    virtual void SetSegmentationModel(Int_t dettype,AliITSsegmentation *seg);
    virtual AliITSsegmentation* GetSegmentationModel(Int_t dettype) const;
    virtual AliITSsegmentation* GetSegmentationModelByModule(Int_t module) const;

    virtual void SetCalibrationModel(Int_t iMod,AliITSCalibration *resp);
    virtual void SetSPDNoisyModel(Int_t iMod, AliITSCalibration *cal);
    virtual void SetSPDSparseDeadModel(Int_t iMod, AliITSCalibration *cal);

    virtual AliITSCalibration* GetCalibrationModel(Int_t iMod) const;
    virtual AliITSCalibration* GetSPDNoisyModel(Int_t iMod) const;
    virtual AliITSTriggerConditions* GetTriggerConditions();

    virtual void SetSimuParam(const AliITSSimuParam* spar){
      if(fSimuPar) delete fSimuPar;
      fSimuPar = new AliITSSimuParam(*spar);
    }
    virtual AliITSSimuParam* GetSimuParam() const {return fSimuPar;}

    virtual AliITSDDLModuleMapSDD* GetDDLModuleMapSDD()const { return fDDLMapSDD;}
    virtual AliITSresponseSDD* GetResponseSDD() const { return fRespSDD;}
    TObjArray* GetCalibrationArray() const {return fCalibration;}
    TObjArray* GetSegmentation() const {return fSegmentation;}
    void ResetCalibrationArray();
    void ResetSegmentation();

    virtual void SetLoader(AliITSLoader* loader);
    AliITSLoader* GetLoader() const {return fLoader;}

    virtual void SetDefaults();
    virtual void SetDefaultSimulation();
    virtual void SetRunNumber(Int_t rn=0){fRunNumber = rn;}
    virtual Int_t GetRunNumber() const {return fRunNumber;}
    virtual void SetTreeAddressS(TTree* treeS, const Char_t* name);
    virtual void SetTreeAddressD(TTree* treeD, const Char_t* name);

    virtual void SetDigits(TObjArray* digits) {fDigits=digits;}
    const TClonesArray* GetSDigits() const { return &fSDigits;}
    TObjArray*    GetDigits() const {return fDigits;}
    Int_t* GetNDigitArray() const {return fNDigits;}
    TClonesArray *DigitsAddress(Int_t id) const {
	return ((TClonesArray*)(*fDigits)[id]);}
    virtual void ResetSDigits(){fNSDigits=0; fSDigits.Clear();}
    virtual void ResetDigits();
    virtual void ResetDigits(Int_t branch);
    virtual void SDigitsToDigits(Option_t *opt, Char_t* name);

    virtual void AddSumDigit(AliITSpListItem &sdig);
    virtual void AddSimDigit(Int_t branch, const AliITSdigit *d);
    virtual void AddSimDigit(Int_t branch,Float_t phys,Int_t* digits,
			     Int_t* tracks,Int_t *hits,Float_t* trkcharges,
			     Int_t sigexpanded=-1000);
    virtual void SetDigitClassName(Int_t i, const Char_t* name) {
	fkDigClassName[i]=name;}
    const Char_t* GetDigitClassName(Int_t i) const {return fkDigClassName[i];}

    virtual void ResetFOSignals() {fFOGenerator.ResetSignals();}
    virtual void ProcessSPDDigitForFastOr(UInt_t module, UInt_t colM, UInt_t rowM);
    virtual void ProcessNoiseForFastOr() {fFOGenerator.ProcessNoise();}
    virtual AliITSFOSignalsSPD* GetFOSignals() {return fFOGenerator.GetFOSignals();}
    virtual void WriteFOSignals();
    virtual Float_t GetAverageGainSDD() const {
      if(fAveGainSDD>0.) return fAveGainSDD;
      else return 1.;
    }


 protected:
    virtual void CreateCalibrationArray(); 
    virtual Bool_t GetCalibration();
    
 private:
    AliITSDetTypeSim(const AliITSDetTypeSim &source);
    AliITSDetTypeSim& operator=(const AliITSDetTypeSim &source);
    void SetDefaultSegmentation(Int_t idet);  // creates def segm.

    //conversion of the old SSD calibration objects tothe new ones
    void ReadOldSSDNoise(const TObjArray *array, 
			 AliITSNoiseSSDv2 *noiseSSD);
    void ReadOldSSDBadChannels(const TObjArray *array, 
			       AliITSBadChannelsSSDv2 *badChannelsSSD);
    void ReadOldSSDGain(const TObjArray *array, 
			AliITSGainSSDv2 *gainSSD);

    static const Int_t fgkNdettypes;          // number of different det. types
    static const Int_t fgkDefaultNModulesSPD; // Total numbers of SPD modules by default
    static const Int_t fgkDefaultNModulesSDD; // Total numbers of SDD modules by default
    static const Int_t fgkDefaultNModulesSSD; // Total numbers of SSD modules by default

    TObjArray    *fSimulation;   //! [NDet]
    TObjArray    *fSegmentation; //! [NDet]
    TObjArray    *fCalibration;  //! [NMod]
    AliITSCalibrationSSD* fSSDCalibration;  //! SSD calibration object
    TObjArray    *fSPDNoisy;     //! [fgkDefaultNModulesSPD]
    TObjArray    *fSPDSparseDead;//! [fgkDefaultNModulesSPD]
    Int_t         fNSDigits;     //! number of SDigits
    TClonesArray  fSDigits;      //! Summable digits
    Int_t*        fNDigits;      //! [NDet] number of Digits for det.
    Int_t         fRunNumber;    //! run number (to access DB)
    TObjArray     *fDigits;      //! [NMod][NDigits]
    AliITSSimuParam *fSimuPar;   //! detector simulation parameters
    AliITSDDLModuleMapSDD *fDDLMapSDD; //! mapping DDL/module -> SDD module number
    AliITSresponseSDD *fRespSDD;  //! SDD response parameters 
    Float_t       fAveGainSDD;    //! Average gain of SDD good anodes
    const Char_t*       fkDigClassName[3]; //! String with digit class name.
    AliITSLoader* fLoader;          //! loader  
    Bool_t        fFirstcall;       //! flag
    AliITSFOGeneratorSPD fFOGenerator; //! Fast-OR generator object
    AliITSTriggerConditions* fTriggerConditions; //! Trigger conditions 
       
    ClassDef(AliITSDetTypeSim,15) // ITS Simulation structure
 
};

#endif
 AliITSDetTypeSim.h:1
 AliITSDetTypeSim.h:2
 AliITSDetTypeSim.h:3
 AliITSDetTypeSim.h:4
 AliITSDetTypeSim.h:5
 AliITSDetTypeSim.h:6
 AliITSDetTypeSim.h:7
 AliITSDetTypeSim.h:8
 AliITSDetTypeSim.h:9
 AliITSDetTypeSim.h:10
 AliITSDetTypeSim.h:11
 AliITSDetTypeSim.h:12
 AliITSDetTypeSim.h:13
 AliITSDetTypeSim.h:14
 AliITSDetTypeSim.h:15
 AliITSDetTypeSim.h:16
 AliITSDetTypeSim.h:17
 AliITSDetTypeSim.h:18
 AliITSDetTypeSim.h:19
 AliITSDetTypeSim.h:20
 AliITSDetTypeSim.h:21
 AliITSDetTypeSim.h:22
 AliITSDetTypeSim.h:23
 AliITSDetTypeSim.h:24
 AliITSDetTypeSim.h:25
 AliITSDetTypeSim.h:26
 AliITSDetTypeSim.h:27
 AliITSDetTypeSim.h:28
 AliITSDetTypeSim.h:29
 AliITSDetTypeSim.h:30
 AliITSDetTypeSim.h:31
 AliITSDetTypeSim.h:32
 AliITSDetTypeSim.h:33
 AliITSDetTypeSim.h:34
 AliITSDetTypeSim.h:35
 AliITSDetTypeSim.h:36
 AliITSDetTypeSim.h:37
 AliITSDetTypeSim.h:38
 AliITSDetTypeSim.h:39
 AliITSDetTypeSim.h:40
 AliITSDetTypeSim.h:41
 AliITSDetTypeSim.h:42
 AliITSDetTypeSim.h:43
 AliITSDetTypeSim.h:44
 AliITSDetTypeSim.h:45
 AliITSDetTypeSim.h:46
 AliITSDetTypeSim.h:47
 AliITSDetTypeSim.h:48
 AliITSDetTypeSim.h:49
 AliITSDetTypeSim.h:50
 AliITSDetTypeSim.h:51
 AliITSDetTypeSim.h:52
 AliITSDetTypeSim.h:53
 AliITSDetTypeSim.h:54
 AliITSDetTypeSim.h:55
 AliITSDetTypeSim.h:56
 AliITSDetTypeSim.h:57
 AliITSDetTypeSim.h:58
 AliITSDetTypeSim.h:59
 AliITSDetTypeSim.h:60
 AliITSDetTypeSim.h:61
 AliITSDetTypeSim.h:62
 AliITSDetTypeSim.h:63
 AliITSDetTypeSim.h:64
 AliITSDetTypeSim.h:65
 AliITSDetTypeSim.h:66
 AliITSDetTypeSim.h:67
 AliITSDetTypeSim.h:68
 AliITSDetTypeSim.h:69
 AliITSDetTypeSim.h:70
 AliITSDetTypeSim.h:71
 AliITSDetTypeSim.h:72
 AliITSDetTypeSim.h:73
 AliITSDetTypeSim.h:74
 AliITSDetTypeSim.h:75
 AliITSDetTypeSim.h:76
 AliITSDetTypeSim.h:77
 AliITSDetTypeSim.h:78
 AliITSDetTypeSim.h:79
 AliITSDetTypeSim.h:80
 AliITSDetTypeSim.h:81
 AliITSDetTypeSim.h:82
 AliITSDetTypeSim.h:83
 AliITSDetTypeSim.h:84
 AliITSDetTypeSim.h:85
 AliITSDetTypeSim.h:86
 AliITSDetTypeSim.h:87
 AliITSDetTypeSim.h:88
 AliITSDetTypeSim.h:89
 AliITSDetTypeSim.h:90
 AliITSDetTypeSim.h:91
 AliITSDetTypeSim.h:92
 AliITSDetTypeSim.h:93
 AliITSDetTypeSim.h:94
 AliITSDetTypeSim.h:95
 AliITSDetTypeSim.h:96
 AliITSDetTypeSim.h:97
 AliITSDetTypeSim.h:98
 AliITSDetTypeSim.h:99
 AliITSDetTypeSim.h:100
 AliITSDetTypeSim.h:101
 AliITSDetTypeSim.h:102
 AliITSDetTypeSim.h:103
 AliITSDetTypeSim.h:104
 AliITSDetTypeSim.h:105
 AliITSDetTypeSim.h:106
 AliITSDetTypeSim.h:107
 AliITSDetTypeSim.h:108
 AliITSDetTypeSim.h:109
 AliITSDetTypeSim.h:110
 AliITSDetTypeSim.h:111
 AliITSDetTypeSim.h:112
 AliITSDetTypeSim.h:113
 AliITSDetTypeSim.h:114
 AliITSDetTypeSim.h:115
 AliITSDetTypeSim.h:116
 AliITSDetTypeSim.h:117
 AliITSDetTypeSim.h:118
 AliITSDetTypeSim.h:119
 AliITSDetTypeSim.h:120
 AliITSDetTypeSim.h:121
 AliITSDetTypeSim.h:122
 AliITSDetTypeSim.h:123
 AliITSDetTypeSim.h:124
 AliITSDetTypeSim.h:125
 AliITSDetTypeSim.h:126
 AliITSDetTypeSim.h:127
 AliITSDetTypeSim.h:128
 AliITSDetTypeSim.h:129
 AliITSDetTypeSim.h:130
 AliITSDetTypeSim.h:131
 AliITSDetTypeSim.h:132
 AliITSDetTypeSim.h:133
 AliITSDetTypeSim.h:134
 AliITSDetTypeSim.h:135
 AliITSDetTypeSim.h:136
 AliITSDetTypeSim.h:137
 AliITSDetTypeSim.h:138
 AliITSDetTypeSim.h:139
 AliITSDetTypeSim.h:140
 AliITSDetTypeSim.h:141
 AliITSDetTypeSim.h:142
 AliITSDetTypeSim.h:143
 AliITSDetTypeSim.h:144
 AliITSDetTypeSim.h:145
 AliITSDetTypeSim.h:146
 AliITSDetTypeSim.h:147
 AliITSDetTypeSim.h:148
 AliITSDetTypeSim.h:149
 AliITSDetTypeSim.h:150
 AliITSDetTypeSim.h:151
 AliITSDetTypeSim.h:152
 AliITSDetTypeSim.h:153
 AliITSDetTypeSim.h:154
 AliITSDetTypeSim.h:155
 AliITSDetTypeSim.h:156
 AliITSDetTypeSim.h:157
 AliITSDetTypeSim.h:158
 AliITSDetTypeSim.h:159
 AliITSDetTypeSim.h:160
 AliITSDetTypeSim.h:161
 AliITSDetTypeSim.h:162
 AliITSDetTypeSim.h:163
 AliITSDetTypeSim.h:164
 AliITSDetTypeSim.h:165
 AliITSDetTypeSim.h:166
 AliITSDetTypeSim.h:167
 AliITSDetTypeSim.h:168