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::SimHitPrinter ( std::string  filename)

Definition at line 14 of file SimHitPrinter.cc.

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 }

References f, corrVsCorr::filename, MillePedeFileConverter_cfg::out, callgraph::previous, and theFile.

◆ ~SimHitPrinter()

SimHitPrinter::~SimHitPrinter ( )

Definition at line 27 of file SimHitPrinter.cc.

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

Member Function Documentation

◆ printEloss()

void SimHitPrinter::printEloss ( float  eloss) const

Definition at line 75 of file SimHitPrinter.cc.

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

References gather_cfg::cout.

◆ printGlobal()

void SimHitPrinter::printGlobal ( GlobalPoint  global) const

Definition at line 93 of file SimHitPrinter.cc.

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 }

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

◆ printId()

void SimHitPrinter::printId ( int  id) const

Definition at line 51 of file SimHitPrinter.cc.

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 }

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

Referenced by MuonSensitiveDetector::saveHit().

◆ printLocal()

void SimHitPrinter::printLocal ( LocalPoint  localen,
LocalPoint  localex 
) const

Definition at line 81 of file SimHitPrinter.cc.

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 }

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

Referenced by MuonSensitiveDetector::saveHit().

◆ printPabs()

void SimHitPrinter::printPabs ( float  pabs) const

Definition at line 69 of file SimHitPrinter.cc.

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

References gather_cfg::cout.

◆ printTrack()

void SimHitPrinter::printTrack ( int  id) const

Definition at line 60 of file SimHitPrinter.cc.

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 }

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

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

◆ startNewEvent()

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 }

References EgammaValidation_cff::num.

◆ startNewSimHit()

void SimHitPrinter::startNewSimHit ( std::string  s)

Definition at line 31 of file SimHitPrinter.cc.

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 }

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

Referenced by MuonSensitiveDetector::saveHit().

Member Data Documentation

◆ theFile

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

Definition at line 39 of file SimHitPrinter.h.

Referenced by SimHitPrinter().

f
double f[11][100]
Definition: MuScleFitUtils.cc:78
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
SimHitPrinter::theFile
static std::atomic< std::ofstream * > theFile
Definition: SimHitPrinter.h:39
gather_cfg.cout
cout
Definition: gather_cfg.py:144
callgraph.previous
previous
Definition: callgraph.py:95
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
alignCSCRings.s
s
Definition: alignCSCRings.py:92
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:33
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31