test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Private Attributes
SimHitPrinter Class Reference

#include <SimHitPrinter.h>

Public Member Functions

void printEloss (float) const
 
void printGlobal (GlobalPoint) const
 
void printId (int) const
 
void printLocal (LocalPoint, LocalPoint) const
 
void printPabs (float) const
 
void printTrack (int) const
 
 SimHitPrinter (std::string)
 
void startNewEvent (int)
 
void startNewSimHit (std::string)
 
 ~SimHitPrinter ()
 

Static Private Attributes

static std::atomic
< std::ofstream * > 
theFile
 

Detailed Description

class to print sim hits for validation and debugging

Author
Tommaso Boccali Tomma.nosp@m.so.B.nosp@m.occal.nosp@m.i@ce.nosp@m.rn.ch Arno Straesser Arno..nosp@m.Stra.nosp@m.essne.nosp@m.r@ce.nosp@m.rn.ch

Modification:

Definition at line 23 of file SimHitPrinter.h.

Constructor & Destructor Documentation

SimHitPrinter::SimHitPrinter ( std::string  filename)

Definition at line 14 of file SimHitPrinter.cc.

References f, GenerateHcalLaserBadRunList::out, and theFile.

14  {
15  if (theFile) return;
16  const char* theName = filename.c_str();
17  auto f = std::make_unique<std::ofstream>(theName, std::ios::out);
18 
19  std::ofstream* previous = nullptr;
20  if(theFile.compare_exchange_strong(previous,f.get()) ) {
21  //this thread was the first one to try to set the value
22  f.release();
23  }
24 }
double f[11][100]
static std::atomic< std::ofstream * > theFile
Definition: SimHitPrinter.h:38
tuple filename
Definition: lut2db_cfg.py:20
SimHitPrinter::~SimHitPrinter ( )

Definition at line 26 of file SimHitPrinter.cc.

26  {
27  // theFile->close();
28 }

Member Function Documentation

void SimHitPrinter::printEloss ( float  eloss) const

Definition at line 74 of file SimHitPrinter.cc.

References gather_cfg::cout.

74  {
75  std::cout << " Eloss: "<<eloss<<std::endl;
76  std::lock_guard<std::mutex> guard{fileMutex};
77  (*theFile) << " e "<<eloss;
78 }
tuple cout
Definition: gather_cfg.py:145
void SimHitPrinter::printGlobal ( GlobalPoint  global) const

Definition at line 94 of file SimHitPrinter.cc.

References gather_cfg::cout, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by MuonSensitiveDetector::saveHit().

94  {
95  std::cout << " Global(en): "<<global.x()<<" "<< global.y()<<" "
96  <<global.z()<<std::endl;
97  std::lock_guard<std::mutex> guard{fileMutex};
98  (*theFile).width(10);
99  (*theFile).setf(std::ios::right,std::ios::adjustfield);
100  (*theFile).setf(std::ios::floatfield);
101  (*theFile).precision(6);
102  (*theFile) << " gl "<<global.x()<<" "<< global.y()<<" "
103  <<global.z()<<std::endl;
104 }
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
tuple cout
Definition: gather_cfg.py:145
T x() const
Definition: PV3DBase.h:62
void SimHitPrinter::printId ( int  id) const

Definition at line 50 of file SimHitPrinter.cc.

References gather_cfg::cout.

Referenced by MuonSensitiveDetector::saveHit().

50  {
51  std::cout << " Id: "<<id<<std::endl;
52  std::lock_guard<std::mutex> guard{fileMutex};
53  (*theFile) << " id ";
54  (*theFile).width(10);
55  (*theFile).setf(std::ios::right,std::ios::adjustfield);
56  (*theFile) <<id;
57 }
tuple cout
Definition: gather_cfg.py:145
void SimHitPrinter::printLocal ( LocalPoint  localen,
LocalPoint  localex 
) const

Definition at line 80 of file SimHitPrinter.cc.

References gather_cfg::cout, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by MuonSensitiveDetector::saveHit().

80  {
81  std::cout << " Local(en/ex): "<<localen.x()<<" "<< localen.y()<<" "
82  <<localen.z()<<" / "<<localex.x()<<" "<< localex.y()<<" "
83  <<localex.z()<<std::endl;
84  std::lock_guard<std::mutex> guard{fileMutex};
85  (*theFile).width(10);
86  (*theFile).setf(std::ios::right,std::ios::adjustfield);
87  (*theFile).setf(std::ios::floatfield);
88  (*theFile).precision(6);
89  (*theFile) << " en/ex "<<localen.x()<<" "<< localen.y()<<" "
90  <<localen.z()<<" / "<<localex.x()<<" "<< localex.y()<<" "
91  <<localex.z();
92 }
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
tuple cout
Definition: gather_cfg.py:145
T x() const
Definition: PV3DBase.h:62
void SimHitPrinter::printPabs ( float  pabs) const

Definition at line 68 of file SimHitPrinter.cc.

References gather_cfg::cout.

68  {
69  std::cout << " Pabs: "<<pabs<<std::endl;
70  std::lock_guard<std::mutex> guard{fileMutex};
71  (*theFile) << " p "<<pabs;
72 }
tuple cout
Definition: gather_cfg.py:145
void SimHitPrinter::printTrack ( int  id) const

Definition at line 59 of file SimHitPrinter.cc.

References gather_cfg::cout.

59  {
60  std::cout << " Track: "<<id<<std::endl;
61  std::lock_guard<std::mutex> guard{fileMutex};
62  (*theFile) << " trk ";
63  (*theFile).width(10);
64  (*theFile).setf(std::ios::right,std::ios::adjustfield);
65  (*theFile) << id;
66 }
tuple cout
Definition: gather_cfg.py:145
void SimHitPrinter::startNewEvent ( int  num)

Definition at line 45 of file SimHitPrinter.cc.

45  {
46  std::lock_guard<std::mutex> guard{fileMutex};
47  (*theFile) << "Event "<<num<<std::endl;
48 }
void SimHitPrinter::startNewSimHit ( std::string  s)

Definition at line 30 of file SimHitPrinter.cc.

References gather_cfg::cout, and alignCSCRings::s.

Referenced by MuonSensitiveDetector::saveHit().

30  {
31  std::cout.width(10);
32  std::cout.setf(std::ios::right,std::ios::adjustfield);
33  std::cout.setf(std::ios::scientific,std::ios::floatfield);
34  std::cout.precision(6);
35  std::cout << "SimHit in "<<s<<std::endl;
36 
37  std::lock_guard<std::mutex> guard{fileMutex};
38  (*theFile).width(10);
39  (*theFile).setf(std::ios::right,std::ios::adjustfield);
40  (*theFile).setf(std::ios::scientific|std::ios::uppercase|std::ios::showpos,std::ios::floatfield);
41  (*theFile).precision(5);
42  (*theFile) << "SimHit in "<<s;
43 }
tuple cout
Definition: gather_cfg.py:145

Member Data Documentation

std::atomic< std::ofstream * > SimHitPrinter::theFile
staticprivate

Definition at line 38 of file SimHitPrinter.h.

Referenced by SimHitPrinter().