00001 #ifndef DSOPSTACKACTION_H
00002 #define DSOPSTACKACTION_H 1
00003
00004 #include <iostream>
00005 #include <map>
00006 #include <vector>
00007
00008 #include "globals.hh"
00009 #include "G4UserStackingAction.hh"
00010 #include "GaudiAlg/GaudiTool.h"
00011 #include "GiGa/GiGaStackActionBase.h"
00012 #include "GaudiKernel/RndmGenerators.h"
00013
00014 #ifdef DSFMSA_DEBUGPOSITION
00015 class TTree;
00016 class TFile;
00017 #endif
00018
00019 class G4Track;
00020 class G4VTouchable;
00021 class IGeometryInfo;
00022 class ICoordSysSvc;
00023 class IDetectorElement;
00024 using namespace std;
00025
00026 class DsFastMuonStackAction : public GiGaStackActionBase
00027 {
00028 public:
00029
00030 DsFastMuonStackAction( const std::string& type , const std::string& name , const IInterface* parent ) ;
00031 virtual ~DsFastMuonStackAction() {};
00032
00033 virtual StatusCode initialize () ;
00034 virtual StatusCode finalize () ;
00035
00036 virtual G4ClassificationOfNewTrack ClassifyNewTrack( const G4Track* aTrack);
00037 virtual void NewStage();
00038 virtual void PrepareNewEvent();
00039
00040 private:
00041
00042 ICoordSysSvc* m_csvc;
00043 class DECounter {
00044 public:
00045 inline DECounter(G4int maxcount=0, G4double aWeight=1);
00046 inline void operator++(G4int);
00047 inline void reset(G4bool all=false);
00048 G4bool full() { return filled; }
00049 G4int maxCount;
00050 G4int count;
00051 G4double nTracks;
00052 G4bool filled;
00053 G4double weight;
00054 };
00055 std::map<IDetectorElement*, DECounter> fCounter;
00056 std::map<const G4VTouchable*, IDetectorElement*> fTouchablesCache;
00057 std::map<IDetectorElement*, IDetectorElement*> fInsideCache;
00058 G4bool fTrackRemainingPhotons;
00059
00060 std::vector<std::string> m_detectors;
00061 std::vector<G4int> m_limits;
00062 std::vector<G4double> m_weights;
00063 Rndm::Numbers m_uni;
00064
00065 #ifdef DSFMSA_DEBUGPOSITION
00066 TTree* tree;
00067 TFile* file;
00068 double xx,yy,zz;
00069 int ii;
00070 std::map<IDetectorElement*, int> tmpMap;
00071 int event;
00072 #endif
00073 };
00074
00075
00076 DsFastMuonStackAction::DECounter::DECounter(G4int maxcount, G4double aWeight)
00077 : maxCount(maxcount)
00078 , count(0)
00079 , nTracks(0.)
00080 , filled(false)
00081 , weight(aWeight)
00082 {}
00083
00084 void DsFastMuonStackAction::DECounter::reset(G4bool all){
00085 if (all) {
00086 filled=false;
00087 count=0;
00088 nTracks=0.;
00089 }
00090 else if ( !filled ) count=0;
00091 }
00092
00093 void DsFastMuonStackAction::DECounter::operator++(G4int){
00094 count++;
00095 if ( count>=maxCount ) filled=true;
00096 }
00097
00098 #endif
00099