CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/SimG4Core/HelpfulWatchers/src/SimTracer.h

Go to the documentation of this file.
00001 #ifndef HelpfulWatchers_SimTracer_h
00002 #define HelpfulWatchers_SimTracer_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     HelpfulWatchers
00006 // Class  :     SimTracer
00007 // 
00016 //
00017 // Original Author:  
00018 //         Created:  Tue Nov 22 16:41:33 EST 2005
00019 // $Id: SimTracer.h,v 1.2 2005/12/08 21:37:49 chrjones Exp $
00020 //
00021 
00022 // system include files
00023 #include <iostream>
00024 
00025 // user include files
00026 #include "SimG4Core/Notification/interface/Observer.h"
00027 #include "SimG4Core/Watcher/interface/SimWatcher.h"
00028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00029 #include "G4Step.hh"
00030 
00031 // forward declarations
00032 class DDDWorld;
00033 class BeginOfJob;
00034 class BeginOfRun;
00035 class BeginOfEvent;
00036 class BeginOfTrack;
00037 class G4Step;
00038 
00039 class EndOfRun;
00040 class EndOfEvent;
00041 class EndOfTrack;
00042 
00043 #define OBSERVES(type) public Observer<const type*>
00044 #define UPDATE(type) void update(const type*) { std::cout <<"++ signal " #type<<std::endl; }
00045 class SimTracer : public SimWatcher, 
00046 OBSERVES(DDDWorld),
00047 OBSERVES(BeginOfJob),
00048 OBSERVES(BeginOfRun),
00049 OBSERVES(BeginOfEvent),
00050 OBSERVES(BeginOfTrack),
00051 OBSERVES(G4Step),
00052 OBSERVES(EndOfRun),
00053 OBSERVES(EndOfEvent),
00054 OBSERVES(EndOfTrack)
00055 {
00056 
00057    public:
00058    SimTracer(const edm::ParameterSet& pSet) : 
00059    m_verbose(pSet.getUntrackedParameter<bool>("verbose",false)) {
00060    }
00061      //virtual ~SimTracer();
00062 
00063       // ---------- const member functions ---------------------
00064 
00065       // ---------- static member functions --------------------
00066 
00067       // ---------- member functions ---------------------------
00068 UPDATE(DDDWorld)
00069 UPDATE(BeginOfJob)
00070 UPDATE(BeginOfRun)
00071 UPDATE(BeginOfEvent)
00072 UPDATE(BeginOfTrack)
00073    void update(const G4Step* iStep) { 
00074    std::cout <<"++ signal G4Step " ;
00075    if(m_verbose) {
00076       const G4StepPoint* post = iStep->GetPostStepPoint();
00077       const G4ThreeVector pos = post->GetPosition();
00078       std::cout << "( "<<pos.x()<<","<<pos.y()<<","<<pos.z()<<") ";
00079       if(post->GetPhysicalVolume()) {
00080          std::cout << post->GetPhysicalVolume()->GetName();
00081       }
00082    }
00083    std::cout <<std::endl; 
00084 }
00085 //UPDATE(G4Step)
00086 UPDATE(EndOfRun)
00087 UPDATE(EndOfEvent)
00088 UPDATE(EndOfTrack)
00089 
00090    private:
00091      //SimTracer(const SimTracer&); // stop default
00092 
00093      //const SimTracer& operator=(const SimTracer&); // stop default
00094 
00095      // ---------- member data --------------------------------
00096      bool m_verbose;
00097 };
00098 
00099 
00100 #endif