source: trunk/examples/extended/parameterisations/gflash/src/ExGflashSensitiveDetector.cc @ 807

Last change on this file since 807 was 807, checked in by garnier, 16 years ago

update

File size: 4.6 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26// Created by Joanna Weng 26.11.2004
27#include "ExGflashSensitiveDetector.hh"
28#include "ExGflashHitsCollection.hh"
29#include "ExGflashHit.hh"
30#include "G4VPhysicalVolume.hh"
31#include "G4Step.hh"
32#include "G4VTouchable.hh"
33#include "G4TouchableHistory.hh"
34#include "G4SDManager.hh"
35#include <iostream>
36
37//WARNING :  You have to use also  G4VGFlashSensitiveDetector() as base class
38ExGflashSensitiveDetector::ExGflashSensitiveDetector(G4String name, ExGflashDetectorConstruction* det):
39G4VSensitiveDetector(name), G4VGFlashSensitiveDetector(), Detector(det)
40{
41        //@@@@ xN08SensitiveDetector:: evtl name im constructor des G4VGFlashSensitiveDetector ?
42        G4String caloname="ExGflashCollection";
43        collectionName.insert(caloname);
44}
45
46ExGflashSensitiveDetector::~ExGflashSensitiveDetector() {}
47
48void ExGflashSensitiveDetector::Initialize(G4HCofThisEvent*HCE)
49{
50        cout<<"::Initializing the sensitive detector"<<endl;
51        static G4int HCID = -1;
52        if(HCID<0){ HCID = GetCollectionID(0); }
53        HCE->AddHitsCollection( HCID, caloHitsCollection );
54        caloHitsCollection=new 
55        ExGflashHitsCollection(SensitiveDetectorName,collectionName[0]); // first collection
56}
57
58void ExGflashSensitiveDetector::EndOfEvent(G4HCofThisEvent*HCE)
59{
60        if (HCE);       
61        // No Hadronic
62        //    cout<<"IEndOfEvent  " << HCID << endl;
63}
64
65G4bool ExGflashSensitiveDetector::ProcessHits(G4Step* aStep,G4TouchableHistory* ROhist)
66{       //cout<<"This is ProcessHits"<<endl;
67        G4double e=aStep->GetTotalEnergyDeposit();
68        if(e<=0.)return false;
69       
70        G4TouchableHistory* theTouchable
71        = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
72
73        // enrgy deposited -> make Hit
74        //const G4VPhysicalVolume* physVol= aStep->GetPreStepPoint()->GetPhysicalVolume();
75        //G4TouchableHistory* theTouchable = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
76        ExGflashHit* caloHit=new ExGflashHit();
77        caloHit->SetEdep(e);
78        caloHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
79        caloHitsCollection->insert(caloHit);
80        if (ROhist); 
81        G4VPhysicalVolume* physVol = theTouchable->GetVolume();
82        G4int crystalnum=0;
83        for(int i=0;i<100;i++) //@@@@@@@ ExGflashSensitiveDetector:vorsichty
84        {
85                if(physVol == Detector->GetCristal(i))   crystalnum= i;
86        }
87        caloHit->SetCrystalNum(crystalnum);
88       
89        return true;
90}
91
92// Separate GFLASH interface
93G4bool ExGflashSensitiveDetector::ProcessHits(G4GFlashSpot*aSpot ,G4TouchableHistory* ROhist)
94{       //cout<<"This is ProcessHits GFLASH"<<endl;
95        G4double e=aSpot->GetEnergySpot()->GetEnergy();
96        if(e<=0.)return false;
97       
98        G4VPhysicalVolume* pCurrentVolume = aSpot->GetTouchableHandle()->GetVolume();
99       
100        ExGflashHit* caloHit=new ExGflashHit();
101        caloHit->SetEdep(e);
102        caloHit->SetPos(aSpot->GetEnergySpot()->GetPosition());
103        caloHitsCollection->insert(caloHit);
104        if (ROhist); 
105        //cout <<pCurrentVolume->GetName()   << endl;
106        G4int crystalnum=0;
107        for(int i=0;i<100;i++) //@@@@@@@ ExGflashSensitiveDetector:vorsichty
108        {
109                if(pCurrentVolume  == Detector->GetCristal(i))   crystalnum= i;
110        }
111        caloHit->SetCrystalNum(crystalnum);
112       
113        return true;
114}
Note: See TracBrowser for help on using the repository browser.