| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

DsFastMuonStackAction Class Reference

#include <DsFastMuonStackAction.h>

Inheritance diagram for DsFastMuonStackAction:

[legend]
Collaboration diagram for DsFastMuonStackAction:
[legend]
List of all members.

Public Types

 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR
enum  Status
enum  Status
enum  Status

Public Member Functions

 DsFastMuonStackAction (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~DsFastMuonStackAction ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual G4ClassificationOfNewTrack ClassifyNewTrack (const G4Track *aTrack)
virtual void NewStage ()
virtual void PrepareNewEvent ()
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)=0
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)=0
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)=0
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown)
virtual unsigned long addRef ()=0
virtual unsigned long addRef ()=0
virtual unsigned long addRef ()=0
virtual unsigned long addRef ()
virtual unsigned long release ()=0
virtual unsigned long release ()=0
virtual unsigned long release ()=0
StatusCode release (const IInterface *interface) const
virtual unsigned long release ()
virtual const std::string & type () const =0
virtual const std::string & type () const
virtual const IInterfaceparent () const =0
virtual const IInterfaceparent () const
virtual StatusCode configure ()=0
virtual StatusCode configure ()
virtual StatusCode start ()=0
virtual StatusCode start ()
virtual StatusCode stop ()=0
virtual StatusCode stop ()
virtual StatusCode terminate ()=0
virtual StatusCode terminate ()
virtual StatusCode reinitialize ()=0
virtual StatusCode reinitialize ()
virtual StatusCode restart ()=0
virtual StatusCode restart ()
virtual Gaudi::StateMachine::State FSMState () const =0
virtual Gaudi::StateMachine::State FSMState () const
virtual StatusCode sysInitialize ()=0
virtual StatusCode sysInitialize ()
virtual StatusCode sysStart ()=0
virtual StatusCode sysStart ()
virtual StatusCode sysStop ()=0
virtual StatusCode sysStop ()
virtual StatusCode sysFinalize ()=0
virtual StatusCode sysFinalize ()
virtual StatusCode sysReinitialize ()=0
virtual StatusCode sysReinitialize ()
virtual StatusCode sysRestart ()=0
virtual StatusCode sysRestart ()
virtual unsigned long refCount () const =0
virtual const std::string & name () const =0
virtual const std::string & name () const
virtual void handle (const Incident &i)
IGiGaSvcgigaSvc () const
IGiGaSetUpSvcsetupSvc () const
INTupleSvcntupleSvc () const
INTupleSvcevtColSvc () const
IDataProviderSvcdetSvc () const
IDataProviderSvcevtSvc () const
IIncidentSvcincSvc () const
IChronoStatSvcchronoSvc () const
IHistogramSvchistoSvc () const
IAlgContextSvccontextSvc () const
DataObjectput (IDataProviderSvc *svc, DataObject *object, const std::string &address, const bool useRootInTES=true) const
DataObjectput (DataObject *object, const std::string &address, const bool useRootInTES=true) const
Gaudi::Utils::GetData< TYPE
>::return_type 
get (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
Gaudi::Utils::GetData< TYPE
>::return_type 
get (const std::string &location, const bool useRootInTES=true) const
TYPE * getDet (IDataProviderSvc *svc, const std::string &location) const
TYPE * getDet (const std::string &location) const
bool exist (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
bool exist (const std::string &location, const bool useRootInTES=true) const
bool existDet (IDataProviderSvc *svc, const std::string &location) const
bool existDet (const std::string &location) const
TYPE * getOrCreate (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
TYPE * getOrCreate (const std::string &location, const bool useRootInTES=true) const
TOOL * tool (const std::string &type, const std::string &name, const IInterface *parent=0, bool create=true) const
TOOL * tool (const std::string &type, const IInterface *parent=0, bool create=true) const
SERVICE * svc (const std::string &name, const bool create=true) const
IUpdateManagerSvcupdMgrSvc () const
IDataProviderSvcfastContainersSvc () const
StatusCode Error (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
StatusCode Warning (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
StatusCode Print (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const
StatusCode Assert (const bool ok, const std::string &message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
StatusCode Assert (const bool ok, const char *message, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
StatusCode Exception (const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
StatusCode Exception (const std::string &msg, const std::exception &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
StatusCode Exception (const std::string &msg="no message", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
MsgStreammsgStream (const MSG::Level level) const
MsgStreamalways () const
MsgStreamfatal () const
MsgStreamerr () const
MsgStreamerror () const
MsgStreamwarning () const
MsgStreaminfo () const
MsgStreamdebug () const
MsgStreamverbose () const
MsgStreammsg () const
const Statisticscounters () const
StatEntitycounter (const std::string &tag) const
MSG::Level msgLevel () const
bool msgLevel (const MSG::Level level) const
void resetMsgStream () const
bool typePrint () const
bool propsPrint () const
bool statPrint () const
bool errorsPrint () const
long printStat (const MSG::Level level=MSG::ALWAYS) const
long printErrors (const MSG::Level level=MSG::ALWAYS) const
long printProps (const MSG::Level level=MSG::ALWAYS) const
void registerCondition (const std::string &condition, StatusCode(CallerClass::*mf)()=NULL)
void registerCondition (const std::string &condition, CondType *&condPtrDest, StatusCode(CallerClass::*mf)()=NULL)
void registerCondition (char *condition, StatusCode(CallerClass::*mf)()=NULL)
void registerCondition (TargetClass *condition, StatusCode(CallerClass::*mf)()=NULL)
StatusCode runUpdate ()
TransientFastContainer< T > * getFastContainer (const std::string &location, typename TransientFastContainer< T >::size_type initial=0)
const std::string & context () const
const std::string & rootInTES () const
double globalTimeOffset () const
virtual Gaudi::StateMachine::State targetFSMState () const
virtual StatusCode setProperty (const Property &p)
virtual StatusCode setProperty (const std::string &s)
virtual StatusCode setProperty (const std::string &n, const std::string &v)
StatusCode setProperty (const std::string &name, const TYPE &value)
virtual StatusCode getProperty (Property *p) const
virtual const PropertygetProperty (const std::string &name) const
virtual StatusCode getProperty (const std::string &n, std::string &v) const
virtual const std::vector<
Property * > & 
getProperties () const
PropertyMgrgetPropertyMgr ()
ISvcLocatorserviceLocator () const
ISvcLocatorsvcLoc () const
IMessageSvcmsgSvc () const
IToolSvctoolSvc () const
StatusCode setProperties ()
StatusCode service (const std::string &name, T *&svc, bool createIf=true) const
StatusCode service (const std::string &type, const std::string &name, T *&svc) const
void declInterface (const InterfaceID &, void *)
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
IAuditorSvcauditorSvc () const
IMonitorSvcmonitorSvc () const
void declareInfo (const std::string &name, const T &var, const std::string &desc) const
void declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const

Static Public Member Functions

static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()

Public Attributes

 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR

Protected Types

typedef std::map< std::string,
StatEntity
Statistics
typedef std::map< std::string,
unsigned int > 
Counter
typedef std::vector< IAlgTool * > AlgTools
typedef std::pair< IInterface *,
std::string > 
ServiceEntry
typedef std::vector< ServiceEntryServices

Protected Member Functions

virtual unsigned long refCount () const
StatusCode releaseTool (const IAlgTool *tool) const
StatusCode releaseSvc (const IInterface *svc) const
int outputLevel () const
IntegerPropertyoutputLevelProperty ()
void initOutputLevel (Property &prop)

Static Protected Attributes

static const bool IgnoreRootInTES
static const bool UseRootInTES

Private Attributes

ICoordSysSvcm_csvc
std::map< IDetectorElement *,
DECounter
fCounter
std::map< const G4VTouchable *,
IDetectorElement * > 
fTouchablesCache
std::map< IDetectorElement *,
IDetectorElement * > 
fInsideCache
G4bool fTrackRemainingPhotons
std::vector< std::string > m_detectors
std::vector< G4int > m_limits
std::vector< G4double > m_weights
Rndm::Numbers m_uni

Classes

class  DECounter

Detailed Description

Definition at line 26 of file DsFastMuonStackAction.h.


Constructor & Destructor Documentation

DsFastMuonStackAction::DsFastMuonStackAction ( const std::string &  type,
const std::string &  name,
const IInterface parent 
)

Definition at line 44 of file DsFastMuonStackAction.cc.

00047     : GiGaStackActionBase( type, name, parent ) 
00048     , m_csvc(0)
00049     , fTrackRemainingPhotons(false)
00050 { 
00051     declareProperty("Detectors",  m_detectors, "A list with detector elements you are interested in.");
00052     declareProperty("Limits",     m_limits,    "A list with maximal number of photons to start weighting "
00053                                                "for each detector element respectively.");
00054     declareProperty("Weights",    m_weights,   "A list with photon weights for each detector respectively.");
00055 }

virtual DsFastMuonStackAction::~DsFastMuonStackAction (  )  [inline, virtual]

Definition at line 31 of file DsFastMuonStackAction.h.

00031 {};


Member Function Documentation

StatusCode DsFastMuonStackAction::initialize (  )  [virtual]

Reimplemented from GiGaStackActionBase.

Definition at line 57 of file DsFastMuonStackAction.cc.

00058 {
00059     if ( m_detectors.size()!=m_limits.size() || m_limits.size()!=m_weights.size() ){
00060         error() << "Specified parameter lists are inconsistent. Check sizes." << endreq;
00061         return StatusCode::FAILURE;
00062     }
00063     for (unsigned int i(0); i<m_detectors.size(); i++){
00064         IDetectorElement* de=getDet<IDetectorElement>(m_detectors[i]);;
00065         if ( !de ) {
00066             error() << "Detector '"<<m_detectors[i] <<"' not found." << endreq;
00067             return StatusCode::FAILURE;
00068         }
00069 #ifdef DSFMSA_DEBUGPOSITION
00070         tmpMap[de]=int(i)+1;
00071 #endif
00072         fCounter[de]=DECounter(m_limits[i], m_weights[i]);
00073         int size=m_limits[i]*sizeof(G4Track)/1024.;
00074         info()<<"Entry "<<i<<": photons are weighted with w="<<m_weights[i]
00075                            <<", after N="<<m_limits[i]
00076                            <<" (up to "<<size<<" KB) in detector element:"<<endreq;
00077         info() << m_detectors[i] << endreq;
00078     }
00079 
00080     if ( fCounter.empty() ) {
00081         error() << "Got no detector elements to look after" << endreq;
00082         return StatusCode::FAILURE;
00083     }
00084 
00085     StatusCode sc = GiGaStackActionBase::initialize();
00086     if (sc.isFailure()) return sc;
00087    
00088     if ( service("CoordSysSvc", m_csvc).isFailure()) {
00089         error() << " No CoordSysSvc available." << endreq;
00090         return StatusCode::FAILURE;
00091     }
00092   
00093     // set up random numbers
00094     IRndmGenSvc *rgs = 0;
00095     if (service("RndmGenSvc",rgs,true).isFailure()) {
00096         fatal() << "Failed to get random service" << endreq;
00097         return StatusCode::FAILURE;        
00098     }
00099     sc = m_uni.initialize(rgs, Rndm::Flat(0,1));
00100     if (sc.isFailure()) {
00101         fatal() << "Failed to initialize uniform random numbers" << endreq;
00102         return StatusCode::FAILURE;
00103     }
00104 
00105 #ifdef DSFMSA_DEBUGPOSITION
00106     G4cerr<<"create file"<<G4endl;
00107     event=0;
00108     file = new TFile("testCoord.root", "RECREATE");
00109     tree = new TTree("coordtree", "coordinates tree");
00110     tree->Branch("x", &xx, "x/D");
00111     tree->Branch("y", &yy, "y/D");
00112     tree->Branch("z", &zz, "z/D");
00113     tree->Branch("i", &ii, "i/I");
00114     tree->Branch("e", &event, "e/I");
00115 #endif
00116 
00117     return StatusCode::SUCCESS; 
00118 }

StatusCode DsFastMuonStackAction::finalize (  )  [virtual]

Reimplemented from GiGaStackActionBase.

Definition at line 120 of file DsFastMuonStackAction.cc.

00121 {
00122 #ifdef DSFMSA_DEBUGPOSITION
00123   file->Write();
00124   file->Close();
00125 #endif
00126   return  GiGaStackActionBase::finalize();
00127 }

G4ClassificationOfNewTrack DsFastMuonStackAction::ClassifyNewTrack ( const G4Track *  aTrack  )  [virtual]

Reimplemented from GiGaStackActionBase.

Definition at line 129 of file DsFastMuonStackAction.cc.

00129                                                                                          {
00130     //
00131     // Classify new track, and if it is a photon determine whether it should be weighted or not
00132     //
00133     if (aTrack->GetDefinition() != G4OpticalPhoton::OpticalPhotonDefinition()) return fUrgent;
00134     //if ( fTrackRemainingPhotons )  info()<<"track remaining"<<endreq; //debug
00135 
00136     // 
00137     // Determine the whether the track is situated in interesting for us DE or not
00138     //
00139     IDetectorElement* de;
00140     const G4VTouchable* touchable=aTrack->GetTouchable();
00141     std::map<const G4VTouchable*, IDetectorElement*>::iterator cacheIt=fTouchablesCache.find(touchable);
00142     std::map<IDetectorElement*, DECounter>::iterator it, end=fCounter.end();
00143     if ( cacheIt==fTouchablesCache.end() ) {
00144         // 
00145         // cached DE is not found
00146         // determine it and save to cache
00147         //
00148         // info()<<"  cached DE is not found"<<endreq;//debug
00149         Gaudi::XYZPoint position(aTrack->GetPosition().x(),aTrack->GetPosition().y(),aTrack->GetPosition().z());
00150         IDetectorElement* de=m_csvc->belongsToDE(position);
00151         it=fCounter.find(de); 
00152         while ( it==end && de ){ 
00153             // iterate up through the hierarchy of detector elements, 
00154             // until we find the DE we are interested in,
00155             // or at least get to the top of the hierarchy
00156             de=de->parentIDetectorElement();    
00157             it=fCounter.find(de); 
00158         }
00159         //info()<<"  found "<<de<<" points to"<<(int)de<<" end:"<<(it==end)<<endreq;//debug
00160         if ( touchable ) fTouchablesCache[touchable]=de;
00161         else { 
00162             // G4VPhysicalVolume* v=aTrack->GetVolume();
00163             // G4String name=v?v->GetName():"no volume";
00164             // warning()<<"FastMuonStackAction got NULL touchable to '"<<name<<"'. Ignoring..."<<endreq;
00165             return fUrgent;
00166         }
00167         if ( !de ) {// point is not situated in any of DE we are interested in
00168             return fUrgent;
00169         }
00170     }
00171     else {
00172         // cached DE found
00173         // info()<<"  cache found"<<endreq;//debug
00174         de=cacheIt->second;
00175         if ( !de ) {
00176             // point is not situated in any of DE we are interested in
00177             return fUrgent;
00178         }
00179         it=fCounter.find(de);
00180     }
00181 
00182 #ifdef DSFMSA_DEBUGPOSITION
00183     ii=tmpMap[it->first];
00184     if (ii==0){
00185         info()<<"found again strange de"<<endreq;
00186     }
00187     xx=aTrack->GetPosition().x();
00188     yy=aTrack->GetPosition().y();
00189     zz=aTrack->GetPosition().z();
00190     tree->Fill();
00191     if (ii==0) {
00192         G4VPhysicalVolume* v=aTrack->GetVolume();
00193         G4String name=v?v->GetName():"no volume";
00194         info()<<"strange volume"<<it->first->name()<<" "<<name.data()<<endreq;
00195     }
00196 #endif
00197 
00198     DECounter& counter=it->second;
00199     counter++;
00200     G4double tweight=aTrack->GetWeight();
00201     if ( tweight>=counter.weight ) {
00202         // ignore the tracks with high weight
00203         // even if it's logically correct
00204         // large weights are bad
00205         return fUrgent;
00206     }
00207 
00208     if ( !counter.full()  ) {
00209         //number of photons for this DE is small, continue collecting
00210         return fTrackRemainingPhotons?fUrgent:fWaiting;
00211     }
00212       
00213     if( m_uni()>=1./counter.weight ) { 
00214         //info()<<"killed"<<endreq;//debug
00215         return fKill; 
00216     }
00217     
00218     // info()<<"push weighted track"<<endreq;//debug
00219     G4Track* track=const_cast<G4Track*>(aTrack); //yes, it's ugly, but should be safe
00220     track->SetWeight(tweight*counter.weight);
00221     counter.nTracks++;
00222     return fUrgent;
00223 }

void DsFastMuonStackAction::NewStage (  )  [virtual]

Reimplemented from GiGaStackActionBase.

Definition at line 225 of file DsFastMuonStackAction.cc.

00226 {
00227     // 
00228     // The Urgent stack is empty. It means that all possible particles are simulated
00229     // except the photons, delayed fo several DEs.
00230     // info()<<"New stage, reclassifying"<<endreq;
00231     std::map<IDetectorElement*, DECounter>::iterator it, end=fCounter.end();
00232     for ( it=fCounter.begin(); it!=end; it++ ) it->second.reset();
00233     fTrackRemainingPhotons=true;
00234     stackManager->ReClassify();
00235     fTrackRemainingPhotons=false;
00236     //info()<<"Classification is finished"<<endreq;
00237 }

void DsFastMuonStackAction::PrepareNewEvent (  )  [virtual]

Reimplemented from GiGaStackActionBase.

Definition at line 240 of file DsFastMuonStackAction.cc.

00241 {
00242 #ifdef DSFMSA_DEBUGPOSITION
00243     event++; 
00244 #endif
00245     fTrackRemainingPhotons=false;
00246     std::map<IDetectorElement*, DECounter>::iterator it, end=fCounter.end();
00247     for ( it=fCounter.begin(); it!=end; it++ ){
00248         DECounter& c=it->second;
00249         if ( c.full() ) 
00250             info()<<c.nTracks<<" tracks for "<<        
00251                     c.count-c.maxCount<<" photons are simulated in "<<
00252                     it->first->name()<<endreq;
00253 
00254         c.reset(true);
00255     }
00256 }


Member Data Documentation

ICoordSysSvc* DsFastMuonStackAction::m_csvc [private]

Definition at line 42 of file DsFastMuonStackAction.h.

std::map<IDetectorElement*, DECounter> DsFastMuonStackAction::fCounter [private]

Definition at line 55 of file DsFastMuonStackAction.h.

std::map<const G4VTouchable*, IDetectorElement*> DsFastMuonStackAction::fTouchablesCache [private]

Definition at line 56 of file DsFastMuonStackAction.h.

std::map<IDetectorElement*, IDetectorElement*> DsFastMuonStackAction::fInsideCache [private]

Definition at line 57 of file DsFastMuonStackAction.h.

G4bool DsFastMuonStackAction::fTrackRemainingPhotons [private]

Definition at line 58 of file DsFastMuonStackAction.h.

std::vector<std::string> DsFastMuonStackAction::m_detectors [private]

Definition at line 60 of file DsFastMuonStackAction.h.

std::vector<G4int> DsFastMuonStackAction::m_limits [private]

Definition at line 61 of file DsFastMuonStackAction.h.

std::vector<G4double> DsFastMuonStackAction::m_weights [private]

Definition at line 62 of file DsFastMuonStackAction.h.

Rndm::Numbers DsFastMuonStackAction::m_uni [private]

Definition at line 63 of file DsFastMuonStackAction.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:53:27 2011 for DetSim by doxygen 1.4.7