CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/SimG4CMS/Tracker/src/TkSimHitPrinter.cc

Go to the documentation of this file.
00001 #include "SimG4CMS/Tracker/interface/TkSimHitPrinter.h"
00002 
00003 #include <iomanip>
00004 #include <fstream>
00005 
00006 #include "G4Track.hh"
00007 
00008 std::ofstream * TkSimHitPrinter::theFile(0);
00009 
00010 TkSimHitPrinter::TkSimHitPrinter(std::string filename){
00011   if (theFile) return;
00012   const char* theName = filename.c_str();
00013   theFile = new std::ofstream(theName, std::ios::out);
00014 }
00015 
00016 TkSimHitPrinter::~TkSimHitPrinter(){
00017   //  theFile->close();
00018 }
00019 
00020 void TkSimHitPrinter::startNewSimHit(std::string s, std::string d, int i,int j,int eve){
00021   (*theFile) <<"Event: "<<eve<<" "<<s<<" "<<d<<" "<<i<<" Track "<<j;
00022 }
00023 
00024 void TkSimHitPrinter::printLocal(Local3DPoint  p,Local3DPoint e ) const{
00025   (*theFile) << " Local: "<<p.x()<<" "<<p.y()<<" "<<p.z()
00026              <<" ; "<<e.x()<<" "<<e.y()<<" "<<e.z();
00027 }
00028 
00029 void TkSimHitPrinter::printGlobal(Local3DPoint  p ,Local3DPoint  e ) const {
00030   (*theFile) << " Global: "<<p.x()<<" "<<p.y()<<" "<<p.z()
00031              <<" ; "<<e.x()<<" "<<e.y()<<" "<<e.z();
00032 }
00033 
00034 void TkSimHitPrinter::printHitData(float energy, float tof) const {
00035   (*theFile)<< " Energy: "<<energy<<" ToF: "<<tof;
00036 }
00037 void TkSimHitPrinter::printMomentumOfTrack(float m, std::string s, int sign)const {
00038   (*theFile)<<" Momentum "<<m*sign<<" Particle "<<s;
00039 }
00040 void TkSimHitPrinter::printGlobalMomentum(float px, float py,float pz)const {
00041   (*theFile)<<" Momentum "<<px<<" "<<py<<" "<<pz<<std::endl;
00042 }
00043 int TkSimHitPrinter::getPropagationSign(Local3DPoint  p ,Local3DPoint  e ){
00044   float dr;
00045   dr = p.x()*(e-p).x()+ p.y()*(e-p).y()+p.z()*(e-p).z();
00046   if (dr>0) return +1;
00047   return -1;
00048 }