Go to the documentation of this file.00001 #include "SimG4CMS/Muon/interface/SimHitPrinter.h"
00002
00003 #include<iomanip>
00004 #include<iostream>
00005
00006 std::ofstream * SimHitPrinter::theFile(0);
00007
00008 SimHitPrinter::SimHitPrinter(std::string filename){
00009 if (theFile) return;
00010 const char* theName = filename.c_str();
00011 theFile = new std::ofstream(theName, std::ios::out);
00012 }
00013
00014 SimHitPrinter::~SimHitPrinter(){
00015
00016 }
00017
00018 void SimHitPrinter::startNewSimHit(std::string s){
00019 std::cout.width(10);
00020 std::cout.setf(std::ios::right,std::ios::adjustfield);
00021 std::cout.setf(std::ios::scientific,std::ios::floatfield);
00022 std::cout.precision(6);
00023 std::cout << "SimHit in "<<s<<std::endl;
00024 (*theFile).width(10);
00025 (*theFile).setf(std::ios::right,std::ios::adjustfield);
00026 (*theFile).setf(std::ios::scientific|std::ios::uppercase|std::ios::showpos,std::ios::floatfield);
00027 (*theFile).precision(5);
00028 (*theFile) << "SimHit in "<<s;
00029 }
00030
00031 void SimHitPrinter::startNewEvent(int num){
00032 (*theFile) << "Event "<<num<<std::endl;
00033 }
00034
00035 void SimHitPrinter::printId(int id) const{
00036 std::cout << " Id: "<<id<<std::endl;
00037 (*theFile) << " id ";
00038 (*theFile).width(10);
00039 (*theFile).setf(std::ios::right,std::ios::adjustfield);
00040 (*theFile) <<id;
00041 }
00042
00043 void SimHitPrinter::printTrack(int id) const{
00044 std::cout << " Track: "<<id<<std::endl;
00045 (*theFile) << " trk ";
00046 (*theFile).width(10);
00047 (*theFile).setf(std::ios::right,std::ios::adjustfield);
00048 (*theFile) << id;
00049 }
00050
00051 void SimHitPrinter::printPabs(float pabs) const{
00052 std::cout << " Pabs: "<<pabs<<std::endl;
00053 (*theFile) << " p "<<pabs;
00054 }
00055
00056 void SimHitPrinter::printEloss(float eloss) const{
00057 std::cout << " Eloss: "<<eloss<<std::endl;
00058 (*theFile) << " e "<<eloss;
00059 }
00060
00061 void SimHitPrinter::printLocal(LocalPoint localen,LocalPoint localex) const{
00062 (*theFile).width(10);
00063 (*theFile).setf(std::ios::right,std::ios::adjustfield);
00064 (*theFile).setf(std::ios::floatfield);
00065 (*theFile).precision(6);
00066 std::cout << " Local(en/ex): "<<localen.x()<<" "<< localen.y()<<" "
00067 <<localen.z()<<" / "<<localex.x()<<" "<< localex.y()<<" "
00068 <<localex.z()<<std::endl;
00069 (*theFile) << " en/ex "<<localen.x()<<" "<< localen.y()<<" "
00070 <<localen.z()<<" / "<<localex.x()<<" "<< localex.y()<<" "
00071 <<localex.z();
00072 }
00073
00074 void SimHitPrinter::printGlobal(GlobalPoint global) const {
00075 (*theFile).width(10);
00076 (*theFile).setf(std::ios::right,std::ios::adjustfield);
00077 (*theFile).setf(std::ios::floatfield);
00078 (*theFile).precision(6);
00079 std::cout << " Global(en): "<<global.x()<<" "<< global.y()<<" "
00080 <<global.z()<<std::endl;
00081 (*theFile) << " gl "<<global.x()<<" "<< global.y()<<" "
00082 <<global.z()<<std::endl;
00083 }