1#include "CgemDigitizerSvc/IonizationGar.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/Bootstrap.h"
5#include "GaudiKernel/IDataProviderSvc.h"
6#include "GaudiKernel/SmartDataPtr.h"
7#include "GaudiKernel/DataSvc.h"
9#include "CLHEP/Units/PhysicalConstants.h"
17using namespace Garfield;
33 m_magConfig = magConfig;
42 double x0 = 0., y0 = 0., z0 = 0., t0 = 0.;
56 double dx0 = (trkPosOut[0] - trkPosIn[0])/10.0;
57 double dy0 = (trkPosOut[1] - trkPosIn[1])/10.0;
58 double dz0 = (trkPosOut[2] - trkPosIn[2])/10.0;
59 double trkL = sqrt(dx0*dx0 + dy0*dy0 + dz0*dz0);
65 double minX = 0. < dx0 ? 0. : dx0;
66 double maxX = 0. < dx0 ? dx0 : 0.;
67 double minY = 0. < dy0 ? 0. : dy0;
68 double maxY = 0. < dy0 ? dy0 : 0.;
69 double minZ = 0. < dz0 ? 0. : dz0;
70 double maxZ = 0. < dz0 ? dz0 : 0.;
84 string particleType = getParticle(particle, charge);
86 TrackHeed* track =
new TrackHeed();
87 track->SetSensor(m_sensor);
88 if(m_debugging) track->EnableDebugging();
89 else track->DisableDebugging();
90 track->EnableMagneticField();
91 track->SetParticle(particleType);
92 track->SetMomentum(p*1.e9);
94 m_sensor->SetArea(minX, minY, minZ, maxX, maxY, maxZ);
102 track->NewTrack(x0, y0, z0, t0, dx0, dy0, dz0);
108 double xc = 0., yc = 0., zc = 0., tc = 0.;
114 while(track->GetCluster(xc, yc, zc, tc, nc, ec, extra)){
115 double length = sqrt(pow(xc,2)+pow(yc,2)+pow(zc,2));
118 cout <<
"overflow -------------------------" << endl;
123 for(
int j = 0; j<nc; ++j) {
124 double xe, ye, ze, te;
125 double ee, dxe, dye, dze;
126 track->GetElectron(j, xe, ye, ze, te, ee, dxe, dye, dze);
129 m_ex.push_back(trkPosIn[0] + xe*10.0);
130 m_ey.push_back(trkPosIn[1] + ye*10.0);
131 m_ez.push_back(trkPosIn[2] + ze*10.0);
140string IonizationGar::getParticle(
int particle,
int charge)
const{
142 if((0==particle)&&(-1==charge)) {particleName =
"electron";}
143 else if((0==particle)&&(1==charge)) {particleName =
"e+";}
144 else if((1==particle)&&(1==charge)) {particleName =
"mu+";}
145 else if((1==particle)&&(-1==charge)) {particleName =
"mu-";}
146 else if((2==particle)&&(1==charge)) {particleName =
"pi+";}
147 else if((2==particle)&&(-1==charge)) {particleName =
"pi-";}
148 else if((3==particle)&&(1==charge)) {particleName =
"K+";}
149 else if((3==particle)&&(-1==charge)) {particleName =
"K-";}
150 else if((4==particle)&&(1==charge)) {particleName =
"p";}
151 else if((4==particle)&&(-1==charge)) {particleName =
"p-bar";}
153 cout <<
"IonizationGar::getParticle() error";
154 particleName =
"error";
159void IonizationGar::clear(){
167void IonizationGar::initGeoGas(){
168 randomEngine.Seed(m_random);
169 m_gas =
new MediumMagboltz();
170 m_gas->SetComposition(
"ar",90.,
"isobutane",10.);
171 m_gas->SetTemperature(293.15);
172 m_gas->SetPressure(760.0);
173 m_gas->SetMaxElectronEnergy(200.);
174 m_gas->EnablePenningTransfer(0.44, 0.0,
"Ar");
175 m_gas->Initialise(
true);
177 m_box =
new SolidBox(0., 0., 0., 10., 10., 10.);
179 m_geo =
new GeometrySimple();
180 m_geo->AddSolid(m_box, m_gas);
182 m_comp =
new ComponentAnalyticField();
183 if(m_debugging) m_comp->EnableDebugging();
184 else m_comp->DisableDebugging();
185 m_comp->SetGeometry(m_geo);
187 m_sensor =
new Sensor();
188 if(m_debugging) m_sensor->EnableDebugging();
189 else m_sensor->DisableDebugging();
190 m_sensor->AddComponent(m_comp);
void setTrack(int particle, int charge, double p, double trkPosIn[], double trkPosOut[])
void init(unsigned int random, ICgemGeomSvc *geomSvc, double magConfig)