CMS 3D CMS Logo

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, MillePedeFileConverter_cfg::out, and theFile.

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

Definition at line 27 of file SimHitPrinter.cc.

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

Member Function Documentation

void SimHitPrinter::printEloss ( float  eloss) const

Definition at line 75 of file SimHitPrinter.cc.

References gather_cfg::cout.

75  {
76  std::cout << " Eloss: " << eloss << std::endl;
77  std::lock_guard<std::mutex> guard{fileMutex};
78  (*theFile) << " e " << eloss;
79 }
void SimHitPrinter::printGlobal ( GlobalPoint  global) const

Definition at line 93 of file SimHitPrinter.cc.

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

93  {
94  std::cout << " Global(en): " << global.x() << " " << global.y() << " " << global.z() << std::endl;
95  std::lock_guard<std::mutex> guard{fileMutex};
96  (*theFile).width(10);
97  (*theFile).setf(std::ios::right, std::ios::adjustfield);
98  (*theFile).setf(std::ios::floatfield);
99  (*theFile).precision(6);
100  (*theFile) << " gl " << global.x() << " " << global.y() << " " << global.z() << std::endl;
101 }
T y() const
Definition: PV3DBase.h:60
T z() const
Definition: PV3DBase.h:61
T x() const
Definition: PV3DBase.h:59
void SimHitPrinter::printId ( int  id) const

Definition at line 51 of file SimHitPrinter.cc.

References gather_cfg::cout, and triggerObjects_cff::id.

Referenced by MuonSensitiveDetector::saveHit().

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

Definition at line 81 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().

81  {
82  std::cout << " Local(en/ex): " << localen.x() << " " << localen.y() << " " << localen.z() << " / " << localex.x()
83  << " " << localex.y() << " " << 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() << " " << localen.z() << " / " << localex.x() << " "
90  << localex.y() << " " << localex.z();
91 }
T y() const
Definition: PV3DBase.h:60
T z() const
Definition: PV3DBase.h:61
T x() const
Definition: PV3DBase.h:59
void SimHitPrinter::printPabs ( float  pabs) const

Definition at line 69 of file SimHitPrinter.cc.

References gather_cfg::cout.

69  {
70  std::cout << " Pabs: " << pabs << std::endl;
71  std::lock_guard<std::mutex> guard{fileMutex};
72  (*theFile) << " p " << pabs;
73 }
void SimHitPrinter::printTrack ( int  id) const

Definition at line 60 of file SimHitPrinter.cc.

References gather_cfg::cout, and triggerObjects_cff::id.

Referenced by ntuplePrintersDiff.TrackPrinter::diff(), and ntuplePrintersDiff.TrackPrinter::printTrackAndMatchedTrackingParticles().

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

Definition at line 46 of file SimHitPrinter.cc.

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

Definition at line 31 of file SimHitPrinter.cc.

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

Referenced by MuonSensitiveDetector::saveHit().

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

Member Data Documentation

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

Definition at line 39 of file SimHitPrinter.h.

Referenced by SimHitPrinter().