5#include "CgemDigitizerSvc/IonizationGTS.h"
7#include "GaudiKernel/ISvcLocator.h"
8#include "GaudiKernel/Bootstrap.h"
9#include "GaudiKernel/IDataProviderSvc.h"
10#include "GaudiKernel/SmartDataPtr.h"
11#include "GaudiKernel/DataSvc.h"
13#include "CLHEP/Units/PhysicalConstants.h"
26#define N_PRI_AVE 18.0016
29const double int_prob_electron_per_cluster[100]={0.902864,0.920309,0.93045,0.936283,0.940138,0.943808,0.948277,0.954485,0.96098,0.966479,
30 0.970936,0.974523,0.977442,0.979843,0.981959,0.983657,0.985152,0.986421,0.987404,0.988233,
31 0.990002,0.990783,0.991482,0.992107,0.992666,0.993168,0.99362,0.994028,0.994397,0.994731,
32 0.995036,0.995313,0.995567,0.9958,0.996015,0.996212,0.996395,0.996564,0.996721,0.996867,
33 0.997003,0.99713,0.997248,0.99736,0.997464,0.997562,0.997655,0.997742,0.997825,0.997903,
34 0.997976,0.998046,0.998113,0.998176,0.998236,0.998293,0.998348,0.9984,0.998449,0.998497,
35 0.998542,0.998586,0.998628,0.998668,0.998706,0.998743,0.998779,0.998813,0.998846,0.998877,
36 0.998908,0.998938,0.998966,0.998993,0.99902,0.999046,0.999071,0.999095,0.999118,0.99914,
37 0.999162,0.999183,0.999204,0.999224,0.999243,0.999262,0.99928,0.999298,0.999315,0.999332,
38 0.999348,0.999364,0.99938,0.999395,0.99941,0.999424,0.999438,0.999452,0.999465,0.999478};
53 double time_spent = 0.;
54 clock_t begin = clock();
58 gRandom->SetSeed(m_random);
60 m_magConfig = magConfig;
62 cout <<
"IonizationGTS::init: m_testing " <<
m_testing << endl;
66 output =
new TFile(
"ionization.root",
"RECREATE");
67 h_distance_cluster =
new TH1F(
"h_distance_cluster",
"distance between two consecutive clusters", 100, 0, 5);
68 h_nof_cluster =
new TH1F(
"h_nof_cluster",
"number of clusters", 100, 0, 100);
71 clock_t end = clock();
72 time_spent += (double)(end - begin) / CLOCKS_PER_SEC;
79 double time_spent = 0.;
80 clock_t begin = clock();
86 m_track_length_limit = TMath::Sqrt((trkPosOut[0] - trkPosIn[0])*(trkPosOut[0] - trkPosIn[0]) + (trkPosOut[1] - trkPosIn[1])*(trkPosOut[1] - trkPosIn[1]) + (trkPosOut[2] - trkPosIn[2])*(trkPosOut[2] - trkPosIn[2]));
89 m_n_ion_mm =
N_PRI_AVE/m_track_length_limit;
109 if(!is_inside)
break;
113 m_nIonE += nof_sec_ele;
132 double distance = TMath::Sqrt((last_x -
x)*(last_x -
x) + (last_y - y)*(last_y - y) + (last_z - z)*(last_z - z));
133 h_distance_cluster->Fill(distance);
141 for(
int iele = 0; iele < nof_sec_ele + 1; iele++)
154 if(m_nIonE != m_ex.size()) std::cout <<
"IonizationGTS::setTrack ERRRRRRRRRRRRRROR" << std::endl;
156 if(
m_testing==
true) h_nof_cluster->Fill(counter-1);
158 clock_t end = clock();
159 time_spent += (double)(end - begin) / CLOCKS_PER_SEC;
160 cout <<
"Sampling::ionization " << m_nIonE <<
" time " << time_spent <<
" seconds" << endl;
171 double u = gRandom->Uniform(0, 1);
173 double dl_extracted = -(1./m_n_ion_mm) * TMath::Log(1 - u);
174 m_track_length += dl_extracted;
179 if(m_track_length > m_track_length_limit)
return false;
190 double prob = gRandom->Uniform(0, 1);
192 for(
int iele = 0; iele < 100; iele++) {
198 std::cout <<
"IonizationGTS::generate_secondary_ele: increase the size above 100"<<endl;
207 double t = (m_track_length_limit - m_track_length)/m_track_length_limit;
208 x = posin[0] *
t + posout[0] * (1 -
t);
209 y = posin[1] *
t + posout[1] * (1 -
t);
210 z = posin[2] *
t + posout[2] * (1 -
t);
260void IonizationGTS::clear(){
261 m_track_length_limit = 0;
const double int_prob_electron_per_cluster[100]
void init(unsigned int random, ICgemGeomSvc *geomSvc, double magConfig)
void setTrack(int particle, int charge, double p, double trkPosIn[], double trkPosOut[])
void compute_pos(double trkPosIn[], double trkPosOut[], double &x, double &y, double &z)
bool generate_primary_ele()
int generate_secondary_ele()