ROOT logo
#ifndef _KDetector
#define _KDetector

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// KDetector                                                            //
//                                                                      //
// Class for description of silicon microstrip detector                 //
// This function calculates BEGIN_LATEX                                 //
// F(x_{#frac{1}{2}}) = #prod(x < x_{#frac{1}{2}}) = #frac{1}{2}        //
// END_LATEX                                                            //
//////////////////////////////////////////////////////////////////////////


#include "TMath.h"
#include "fizika.h"
#include "nrutil.h"
#include "math.h"
#include <stdio.h>
#include <stdlib.h>
#include "TArray.h"
#include "TArrayI.h"
#include "TArrayF.h"
#include "TArrayD.h"
#include "TString.h"
#include <string.h>
#include "TClonesArray.h"
#include "TObjArray.h"
#include "TRandom.h"
#include "TMath.h"
#include "TLine.h"
#include "TF3.h"
#include "KStruct.h"
#include "TH3S.h"
#include "KGeometry.h"
#include "KMaterial.h"
#include "KField.h"
#include "TVector3.h"

class KDetector : public KGeometry, public KMaterial {

private:
  Double_t Deps;
  TRandom *ran;               //random number generator
  Double_t CalErr;               //Error of the solver
  Int_t MaxIter;              //Maximum number of iterations in eq solver
  Short_t Debug;              //Print information of drift calculation etc.

public:
  Float_t Voltage;  //Voltage
  Float_t Voltage2; //Voltage2 
  TArrayF Voltages; //Array of voltages

  // Definition of space charge 
  TF3     *NeffF;     //effective dopping concentration function
  TH3F    *NeffH;     //effective dopping concentration histogram

  // Weigthing, electric and magnetic field
  KField *Ramo;       // ramo field 
  KField *Real;       // electric field
  Float_t B[3];      // magnetic field

  // Trapping and variables used for multiplication studies
  Float_t taue;      // effective trapping time constants - used if Multiplication is ON
  Float_t tauh;      // effective trapping time constants - used if Multiplication is ON

  Int_t BreakDown;     // if break down occurs it goes to 1 otherwise is 0
  Float_t MTresh;      // treshold for taking multiplication into account
  Float_t BDTresh;     // hole multiplication - break down treshold 

  // Drift parameters

  Float_t enp[3];      //entry point for the charge drift
  Float_t exp[3];      //exit point for the cahrge drift
  Int_t diff;          // Diffusion simulation (yes=1, no=0)
  Int_t average;       // Average (over how many events)
  Float_t SStep;       // Simulation step size;

  // Output histograms
  TH1F *pos;           // contribution of the holes to the total drift current
  TH1F *neg;           // contribution of the electrons  to the total drift current
  TH1F *sum;	       // total drift current

  // Constructors and destructor
  KDetector();
  ~KDetector();
  //_______________________________________________________________________________


  //Configuration functions 
  void ResetRnd(Int_t seed) {delete ran; ran=new TRandom(seed);}; // reset the random generator  
  void SetDriftHisto(Float_t x,Int_t=200);
  void SetCalculationParameters(Double_t x,Int_t y){CalErr=x; MaxIter=y;}

  // Solving the differntial equations
  void Declaration(Int_t);                 // declaration of boundary conditions
  Double_t kappa(int ,int , int , int);    // defining space charge
  Double_t V(int ,int);                    // defining voltage
  void CalField(Int_t);                    // start declaration followed by solving Poisson's equation.
  inline void CalPhyField(){CalField(0);}  
  inline void CalRamoField(){CalField(1);}

  // Calculation in case of any changes
  void SetVoltage(Float_t x,Int_t calnow=1) {Voltage=x; if(calnow) CalPhyField(); };
  void SetNeff(TF3 *neff,Int_t calnow=1) {NeffF=neff; if(calnow) CalPhyField(); };
  void SetNeff(TH3F *neff,Int_t calnow=1) {NeffH=neff; if(calnow) CalPhyField(); };

  // Simulation of drift

  void SetEntryPoint(Float_t x, Float_t y, Float_t z) {enp[0]=x; enp[1]=y; enp[2]=z;};
  void SetExitPoint(Float_t x, Float_t y, Float_t z) {exp[0]=x; exp[1]=y; exp[2]=z;};
  void MipIR(Int_t=20,Float_t=0);
  void ShowMipIR(Int_t, Int_t=14, Int_t=1);
  
  void GaussBeam(Int_t , Float_t , Float_t , Float_t , Float_t , Float_t); //user manca
  void ShowGaussBeam(Int_t , Float_t , Float_t , Float_t , Int_t ,Int_t ); //user manca

  void Drift(Double_t, Double_t, Double_t, Float_t, KStruct *, Double_t = 0);
  void CalM(KStruct *seg, Double_t *data, Int_t=-1); //multiplication calculation

  // visualization 
  TH2F *Draw(Char_t *, Float_t=1);
  TH1F *Draw1D(Char_t *, Float_t ,Int_t ,Float_t );
  // Save,read and debug
  void  Save(Char_t *,Char_t *);
  TFile *Read(Char_t *,Char_t *);
  void  SetDebug(Short_t x) {Debug=x;};
  // precision of drift
  inline void  SetPrecision(Double_t x){Deps=x;};
  inline Double_t   GetPrecision(){return Deps;};
  //______________________________________ 
  //The main detector class = the basis for simulation
  ClassDef(KDetector,1) 
};

#endif


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