Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "LM_SD.h"
00021 #include "LM_Hit.h"
00022 #include "LM_Data.h"
00023 #include "LM_Messenger.h"
00024
00025 #include "EventAction.h"
00026
00027
00028
00029 #include "G4VSensitiveDetector.hh"
00030 #include "G4HCofThisEvent.hh"
00031 #include "G4SDManager.hh"
00032 #include "G4Step.hh"
00033 #include "G4TouchableHistory.hh"
00034 #include "G4TouchableHandle.hh"
00035 #include "G4StepPoint.hh"
00036 #include "G4ThreeVector.hh"
00037
00038 #include "Randomize.hh"
00039
00040
00041
00042 using namespace std;
00043
00044
00045
00046
00047
00048 LM_SD::LM_SD( G4String name ) : G4VSensitiveDetector( name ) {
00049
00050
00051
00052 collectionName.insert( "LM_HC" );
00053
00054
00055
00056 LM_Messenger::Instance()->setLM_SDptr( this );
00057
00058
00059
00060 LM_threshold = 1.0 * eV;
00061 LM_Xresol = 0.01 * cm;
00062 LM_Yresol = 0.01 * cm;
00063
00064
00065
00066 for( int i = 0; i < N_LM; ++i ) LM_Transform[i] = false;
00067 }
00068
00069
00070
00071 LM_SD::~LM_SD(){}
00072
00073
00074
00075 void LM_SD::Initialize( G4HCofThisEvent * HCE ) {
00076
00077 LM_HC = new
00078 LM_HitsCollection( SensitiveDetectorName, collectionName[0] );
00079
00080 static G4int HCID = -1;
00081 if( HCID < 0 ) {
00082 HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
00083 }
00084
00085 HCE->AddHitsCollection( HCID, LM_HC );
00086 }
00087
00088
00089
00090 G4bool LM_SD::ProcessHits( G4Step * step, G4TouchableHistory * ROhist ) {
00091
00092
00093
00094 G4double edep = step->GetTotalEnergyDeposit();
00095
00096
00097
00098 if( edep < LM_threshold ) return false;
00099
00100
00101
00102 G4StepPoint * prestep = step->GetPreStepPoint();
00103
00104 G4TouchableHandle touchable = prestep->GetTouchableHandle();
00105
00106
00107
00108 G4int copyno = touchable->GetCopyNumber();
00109
00110
00111
00112 G4Track * track = step->GetTrack();
00113
00114
00115
00116 G4double time = prestep->GetGlobalTime();
00117 G4int id = track->GetTrackID();
00118
00119
00120
00121 G4ThreeVector trueworld = prestep->GetPosition();
00122
00123
00124
00125 if( !LM_Transform[copyno] ) {
00126 LM_WorldtoLocal[copyno] = touchable->GetHistory()->GetTopTransform();
00127 LM_LocaltoWorld[copyno] = LM_WorldtoLocal[copyno].Inverse();
00128 LM_Transform[copyno] = true;
00129 }
00130
00131 G4ThreeVector truelocal = LM_WorldtoLocal[copyno].TransformPoint(trueworld);
00132
00133
00134
00135 G4ThreeVector local(
00136 truelocal.x() + CLHEP::RandGauss::shoot( 0.0, LM_Xresol ),
00137 truelocal.y() + CLHEP::RandGauss::shoot( 0.0, LM_Yresol ),
00138 truelocal.z() );
00139
00140 G4ThreeVector world = LM_LocaltoWorld[copyno].TransformPoint(local);
00141
00142
00143
00144 LM_Hit * hit = new LM_Hit();
00145
00146
00147
00148 hit->copyno = copyno;
00149 hit->trackid = id;
00150 hit->edep = edep;
00151 hit->time = time;
00152 hit->tworld = trueworld;
00153 hit->tlocal = truelocal;
00154 hit->world = world;
00155 hit->local = local;
00156
00157
00158
00159 LM_HC->insert( hit );
00160
00161
00162
00163 return true;
00164 }
00165
00166
00167
00168 void LM_SD::EndOfEvent( G4HCofThisEvent * HCE ){
00169
00170 LM_Data * lmdata = EventAction::lmdata;
00171
00172 lmdata->Reset();
00173
00174 G4int N_Hits = LM_HC->entries();
00175
00176 lmdata->nLM = N_Hits;
00177
00178 for( G4int i = 0; i < N_Hits; ++i ) {
00179
00180 lmdata->id.push_back( ( *LM_HC )[i]->copyno );
00181 lmdata->tr.push_back( ( *LM_HC )[i]->trackid );
00182
00183 lmdata->e.push_back( ( *LM_HC )[i]->edep / eV );
00184 lmdata->t.push_back( ( *LM_HC )[i]->time / ns );
00185
00186 lmdata->tx.push_back( ( *LM_HC )[i]->tworld.x() / cm );
00187 lmdata->ty.push_back( ( *LM_HC )[i]->tworld.y() / cm );
00188 lmdata->tz.push_back( ( *LM_HC )[i]->tworld.z() / cm );
00189
00190 lmdata->txl.push_back( ( *LM_HC )[i]->tlocal.x() / cm );
00191 lmdata->tyl.push_back( ( *LM_HC )[i]->tlocal.y() / cm );
00192 lmdata->tzl.push_back( ( *LM_HC )[i]->tlocal.z() / cm );
00193
00194 lmdata->x.push_back( ( *LM_HC )[i]->world.x() / cm );
00195 lmdata->y.push_back( ( *LM_HC )[i]->world.y() / cm );
00196 lmdata->z.push_back( ( *LM_HC )[i]->world.z() / cm );
00197
00198 lmdata->xl.push_back( ( *LM_HC )[i]->local.x() / cm );
00199 lmdata->yl.push_back( ( *LM_HC )[i]->local.y() / cm );
00200 lmdata->zl.push_back( ( *LM_HC )[i]->local.z() / cm );
00201 }
00202
00203 }
00204
00205 void LM_SD::clear(){}
00206
00207 void LM_SD::DrawAll() {}
00208
00209
00210
00211 void LM_SD::PrintAll() {
00212 G4int N_Hits = LM_HC->entries();
00213 G4cout << "\nLM Hits Collection N_Hits = " << N_Hits << "\n" << G4endl;
00214 for ( G4int i = 0; i < N_Hits; ++i ) (*LM_HC)[i]->Print();
00215 }
00216
00217
00218
00219 G4double LM_SD::setThreshold( G4double thres ) { return LM_threshold = thres; }
00220 G4double LM_SD::getThreshold() { return LM_threshold; }
00221
00222
00223
00224 G4double LM_SD::setXresol( G4double res ) { return LM_Xresol = res; }
00225 G4double LM_SD::getXresol() { return LM_Xresol; }
00226
00227
00228
00229 G4double LM_SD::setYresol( G4double res ) { return LM_Yresol = res; }
00230 G4double LM_SD::getYresol() { return LM_Yresol; }