From: ivana Date: Mon, 9 Oct 2000 10:59:01 +0000 (+0000) Subject: updated for major upgrade of TG4StepManager (more in doc/history/g4mc_event_History) X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=9bcb6317f908fb6a0406e4a44579b1d1d58cf51b updated for major upgrade of TG4StepManager (more in doc/history/g4mc_event_History) --- diff --git a/AliGeant4/AliLegoSensitiveDetector.cxx b/AliGeant4/AliLegoSensitiveDetector.cxx index ef70a34a3d9..e1887290721 100644 --- a/AliGeant4/AliLegoSensitiveDetector.cxx +++ b/AliGeant4/AliLegoSensitiveDetector.cxx @@ -6,15 +6,12 @@ #include "AliLegoSensitiveDetector.h" #include "AliLego.h" -#include "TG4StepManager.h" - AliLegoSensitiveDetector::AliLegoSensitiveDetector( G4String name, AliLego* lego, G4VSensitiveDetector* standardSD) : TG4VSensitiveDetector(name), fLego(lego), - fStandardSD(standardSD), - fStepManager(TG4StepManager::Instance()) + fStandardSD(standardSD) { // } @@ -26,7 +23,6 @@ AliLegoSensitiveDetector::AliLegoSensitiveDetector( // fLego = right.fLego; fStandardSD = right.fStandardSD; - fStepManager = right.fStepManager; } AliLegoSensitiveDetector::AliLegoSensitiveDetector() { @@ -50,42 +46,19 @@ AliLegoSensitiveDetector::operator=(const AliLegoSensitiveDetector &right) fLego = right.fLego; fStandardSD = right.fStandardSD; - fStepManager = right.fStepManager; return *this; } // public methods -void AliLegoSensitiveDetector::Initialize(G4HCofThisEvent* hc) -{ -// This method is called at the beginning of event action -// before user defined BeginOfEventAction() method. -} - -G4bool AliLegoSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*) +void AliLegoSensitiveDetector::UserProcessHits(const G4Track* track, + const G4Step* step) { // Calls StepManager of associated lego. // --- // let lego process step - fStepManager->SetStep(step, kPostStepPoint); fLego->StepManager(); - - return true; -} - -void AliLegoSensitiveDetector::EndOfEvent(G4HCofThisEvent* hce){ -// } -//void AliLegoSensitiveDetector::clear() -//{} - -void AliLegoSensitiveDetector::PrintAll() { -// -} - -void AliLegoSensitiveDetector::DrawAll() { -// -} diff --git a/AliGeant4/AliLegoSensitiveDetector.h b/AliGeant4/AliLegoSensitiveDetector.h index b48ccacc390..ff9a9c52260 100644 --- a/AliGeant4/AliLegoSensitiveDetector.h +++ b/AliGeant4/AliLegoSensitiveDetector.h @@ -13,7 +13,6 @@ #include class AliLego; -class TG4StepManager; class G4HCofThisEvent; class G4Step; @@ -32,12 +31,7 @@ class AliLegoSensitiveDetector : public TG4VSensitiveDetector AliLegoSensitiveDetector& operator=(const AliLegoSensitiveDetector& right); // methods - virtual void Initialize(G4HCofThisEvent* hc); - virtual G4bool ProcessHits(G4Step* step, G4TouchableHistory* history); - virtual void EndOfEvent(G4HCofThisEvent* hce); - //virtual void clear(); - virtual void PrintAll(); - virtual void DrawAll(); + virtual void UserProcessHits(const G4Track* track, const G4Step* step); // get methods G4VSensitiveDetector* GetStandardSD() const; @@ -49,7 +43,6 @@ class AliLegoSensitiveDetector : public TG4VSensitiveDetector // data members AliLego* fLego; //lego from AliRoot G4VSensitiveDetector* fStandardSD; //standard sensitive detector - TG4StepManager* fStepManager; //TG4StepManager }; // inline methods diff --git a/AliGeant4/AliSensitiveDetector.cxx b/AliGeant4/AliSensitiveDetector.cxx index 4e6c50cf902..92393c13573 100644 --- a/AliGeant4/AliSensitiveDetector.cxx +++ b/AliGeant4/AliSensitiveDetector.cxx @@ -7,12 +7,9 @@ #include "AliModule.h" #include "AliRun.h" -#include "TG4StepManager.h" - AliSensitiveDetector::AliSensitiveDetector(G4String sdName, AliModule* module) : TG4VSensitiveDetector(sdName), - fModule(module), - fStepManager(TG4StepManager::Instance()) + fModule(module) { // } @@ -20,8 +17,7 @@ AliSensitiveDetector::AliSensitiveDetector(G4String sdName, AliModule* module) AliSensitiveDetector::AliSensitiveDetector(G4String sdName, AliModule* module, G4int id) : TG4VSensitiveDetector(sdName, id), - fModule(module), - fStepManager(TG4StepManager::Instance()) + fModule(module) { // } @@ -31,7 +27,6 @@ AliSensitiveDetector::AliSensitiveDetector(const AliSensitiveDetector& right) { // fModule = right.fModule; - fStepManager = right.fStepManager; } AliSensitiveDetector::AliSensitiveDetector(){ @@ -54,66 +49,28 @@ AliSensitiveDetector::operator=(const AliSensitiveDetector& right) TG4VSensitiveDetector::operator=(right); fModule = right.fModule; - fStepManager = right.fStepManager; return *this; } // public methods -void AliSensitiveDetector::Initialize(G4HCofThisEvent* hc) -{ -// This method is called at the beginning of event action -// before user defined BeginOfEventAction() method. -} - -G4bool AliSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*) +void AliSensitiveDetector::UserProcessHits(const G4Track* track, + const G4Step* step) { -// Calls StepManager of associated AliModules. +// Calls StepManager of associated AliModule. // --- // add energy deposit of the current step // directly to AliRun - G4int copy; - gAlice->AddEnergyDeposit(fID, step->GetTotalEnergyDeposit()); + if (step) gAlice->AddEnergyDeposit(fID, step->GetTotalEnergyDeposit()); // parent ID -> shunt - G4int parentID - = step->GetTrack()->GetParentID(); + G4int parentID = track->GetParentID(); Int_t shunt = 0; if (parentID==0) shunt = 1; fModule->SetIshunt(shunt); - if ((step->GetPreStepPoint()->GetStepStatus() == fGeomBoundary) || - (step->GetTrack()->GetCurrentStepNumber() == 1) ){ - - // if first step or crossing boundary - // let AliModule process step in PreStepPoint - // (this ensures compatibility with G3 that - // makes additional step of zero length) - - fStepManager->SetStep(step, kPreStepPoint); - fModule->StepManager(); - } - - // let AliModule process step - fStepManager->SetStep(step, kPostStepPoint); fModule->StepManager(); - - return true; } -void AliSensitiveDetector::EndOfEvent(G4HCofThisEvent* hce){ -// -} - -//void AliSensitiveDetector::clear() -//{} - -void AliSensitiveDetector::PrintAll() { -// -} - -void AliSensitiveDetector::DrawAll() { -// -} diff --git a/AliGeant4/AliSensitiveDetector.h b/AliGeant4/AliSensitiveDetector.h index e06fda8fc6e..382261559a1 100644 --- a/AliGeant4/AliSensitiveDetector.h +++ b/AliGeant4/AliSensitiveDetector.h @@ -13,7 +13,6 @@ #include class AliModule; -class TG4StepManager; class G4HCofThisEvent; class G4Step; @@ -32,12 +31,7 @@ class AliSensitiveDetector : public TG4VSensitiveDetector AliSensitiveDetector& operator=(const AliSensitiveDetector& right); // methods - virtual void Initialize(G4HCofThisEvent* hc); - virtual G4bool ProcessHits(G4Step* step, G4TouchableHistory* history); - virtual void EndOfEvent(G4HCofThisEvent* hce); - //virtual void clear(); - virtual void PrintAll(); - virtual void DrawAll(); + virtual void UserProcessHits(const G4Track* track, const G4Step* step); protected: AliSensitiveDetector(); @@ -45,7 +39,6 @@ class AliSensitiveDetector : public TG4VSensitiveDetector private: // data members AliModule* fModule; //AliModule - TG4StepManager* fStepManager; //TG4StepManager }; #endif //ALI_SENSITIVE_DETECTOR_H diff --git a/AliGeant4/AliSteppingAction.cxx b/AliGeant4/AliSteppingAction.cxx index e3a68181f4b..0a29a454e3d 100644 --- a/AliGeant4/AliSteppingAction.cxx +++ b/AliGeant4/AliSteppingAction.cxx @@ -98,9 +98,11 @@ void AliSteppingAction::PrintTrackInfo(const G4Track* track) const #endif } +#include "AliMC.h" + // public methods -void AliSteppingAction::UserSteppingAction(const G4Step* step) +void AliSteppingAction::SteppingAction(const G4Step* step) { // After processing the given number of steps (kCheckNofSteps) // the particle position is compared with the previus one diff --git a/AliGeant4/AliSteppingAction.h b/AliGeant4/AliSteppingAction.h index dd2b351fa06..44fddba5406 100644 --- a/AliGeant4/AliSteppingAction.h +++ b/AliGeant4/AliSteppingAction.h @@ -7,7 +7,8 @@ #ifndef ALI_STEPPING_ACTION_H #define ALI_STEPPING_ACTION_H -#include +#include "TG4SteppingAction.h" + #include #include @@ -15,7 +16,7 @@ class AliSteppingActionMessenger; class G4Track; -class AliSteppingAction : public G4UserSteppingAction +class AliSteppingAction : public TG4SteppingAction { enum { kCheckNofSteps = 100, @@ -30,7 +31,7 @@ class AliSteppingAction : public G4UserSteppingAction virtual ~AliSteppingAction(); // methods - virtual void UserSteppingAction(const G4Step* step); + virtual void SteppingAction(const G4Step* step); // set methods void SetLoopVerboseLevel(G4int level); diff --git a/AliGeant4/AliTrackingAction.cxx b/AliGeant4/AliTrackingAction.cxx index 0a484ea9f95..0f873110d5b 100644 --- a/AliGeant4/AliTrackingAction.cxx +++ b/AliGeant4/AliTrackingAction.cxx @@ -5,6 +5,7 @@ #include "AliTrackingAction.h" #include "AliTrackingActionMessenger.h" +#include "AliSensitiveDetector.h" #include "AliRun.h" #include "AliGlobals.h" #include "TG4StepManager.h" @@ -13,10 +14,10 @@ #include #include #include +#include #include #include -#include // static data members AliTrackingAction* AliTrackingAction::fgInstance = 0; @@ -94,7 +95,7 @@ void AliTrackingAction::PrepareNewEvent() pStepManager->SetSteppingManager(pG4StepManager); } -void AliTrackingAction::PreUserTrackingAction(const G4Track* aTrack) +void AliTrackingAction::PreTrackingAction(const G4Track* aTrack) { // Called by G4 kernel before starting tracking. // --- @@ -126,10 +127,10 @@ void AliTrackingAction::PreUserTrackingAction(const G4Track* aTrack) // by AlStackingAction in ClassifyNewTrack() method) G4String origin = "secondary"; SaveParticle(aTrack, origin); - }; + } } -void AliTrackingAction::PostUserTrackingAction(const G4Track* aTrack) +void AliTrackingAction::PostTrackingAction(const G4Track* aTrack) { // Called by G4 kernel after finishing tracking. // --- diff --git a/AliGeant4/AliTrackingAction.h b/AliGeant4/AliTrackingAction.h index aa0134446e6..f998be25b8d 100644 --- a/AliGeant4/AliTrackingAction.h +++ b/AliGeant4/AliTrackingAction.h @@ -6,7 +6,8 @@ #ifndef ALI_TRACKING_ACTION_H #define ALI_TRACKING_ACTION_H -#include +#include "TG4TrackingAction.h" + #include #include @@ -15,7 +16,7 @@ class AliTrackingActionMessenger; class G4Track; -class AliTrackingAction : public G4UserTrackingAction +class AliTrackingAction : public TG4TrackingAction { public: AliTrackingAction(); @@ -28,8 +29,8 @@ class AliTrackingAction : public G4UserTrackingAction // methods void PrepareNewEvent(); - virtual void PreUserTrackingAction(const G4Track* aTrack); - virtual void PostUserTrackingAction(const G4Track* aTrack); + virtual void PreTrackingAction(const G4Track* aTrack); + virtual void PostTrackingAction(const G4Track* aTrack); void SaveParticle(const G4Track* track, G4String processName); void SaveAndDestroyTrack(); diff --git a/TGeant4/TG4VSensitiveDetector.cxx b/TGeant4/TG4VSensitiveDetector.cxx index 962ac3589f3..1b04cbbb98d 100644 --- a/TGeant4/TG4VSensitiveDetector.cxx +++ b/TGeant4/TG4VSensitiveDetector.cxx @@ -4,13 +4,13 @@ // See the class description in the header file. #include "TG4VSensitiveDetector.h" - #include "TG4StepManager.h" G4int TG4VSensitiveDetector::fgSDCounter = 0; TG4VSensitiveDetector::TG4VSensitiveDetector(G4String sdName) - : G4VSensitiveDetector(sdName) + : G4VSensitiveDetector(sdName), + fStepManager(TG4StepManager::Instance()) { // fID = fgSDCounter++; @@ -18,7 +18,9 @@ TG4VSensitiveDetector::TG4VSensitiveDetector(G4String sdName) TG4VSensitiveDetector::TG4VSensitiveDetector(G4String sdName, G4int id) : G4VSensitiveDetector(sdName), - fID(id) + fID(id), + fStepManager(TG4StepManager::Instance()) + { // fgSDCounter++; @@ -30,6 +32,7 @@ TG4VSensitiveDetector::TG4VSensitiveDetector( { // fID = right.fID; + fStepManager = right.fStepManager; fgSDCounter++;; } @@ -56,6 +59,34 @@ TG4VSensitiveDetector& TG4VSensitiveDetector::operator=( TG4VSensitiveDetector::operator=(right); fID = right.fID; + fStepManager = right.fStepManager; return *this; } + +// public methods + +G4bool TG4VSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*) +{ +// Calls StepManager of associated AliModule. +// --- + + // let AliModule process step + fStepManager->SetStep(step, kNormalStep); + UserProcessHits(step->GetTrack(), step); + + return true; +} + +G4bool TG4VSensitiveDetector::ProcessHitsOnBoundary(G4Step* step) +{ +// Calls StepManager of associated AliModule +// when crossing a geometrical boundary. +// --- + + fStepManager->SetStep(step, kBoundary); + UserProcessHits(step->GetTrack(), step); + + return true; +} + diff --git a/TGeant4/TG4VSensitiveDetector.h b/TGeant4/TG4VSensitiveDetector.h index 380049f1312..624d0c5b4a7 100644 --- a/TGeant4/TG4VSensitiveDetector.h +++ b/TGeant4/TG4VSensitiveDetector.h @@ -1,7 +1,10 @@ // $Id$ // Category: geometry // -// This class adds integer identifier data member to G4VSensitiveDetector +// This class adds integer identifier data member to G4VSensitiveDetector. +// It also takes care of setting step status (kBoundary, kNormalStep) +// and passing G4Step to TG4StepManager before calling user derived +// sensitive detector class. #ifndef TG4V_SENSITIVE_DETECTOR_H #define TG4V_SENSITIVE_DETECTOR_H @@ -9,6 +12,8 @@ #include #include +class TG4StepManager; + class TG4VSensitiveDetector : public G4VSensitiveDetector { public: @@ -22,6 +27,13 @@ class TG4VSensitiveDetector : public G4VSensitiveDetector // operators TG4VSensitiveDetector& operator=(const TG4VSensitiveDetector &right); + // methods + virtual void UserProcessHits(const G4Track* track, const G4Step* step) = 0; + // the following methods should not + // be overwritten in a derived class + virtual G4bool ProcessHits(G4Step* step, G4TouchableHistory* history); + virtual G4bool ProcessHitsOnBoundary(G4Step* step); + // static get method static G4int GetTotalNofSensitiveDetectors(); @@ -32,7 +44,8 @@ class TG4VSensitiveDetector : public G4VSensitiveDetector TG4VSensitiveDetector(); // data members - G4int fID; //sensitive detector ID + G4int fID; //sensitive detector ID + TG4StepManager* fStepManager; //TG4StepManager private: // data members