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 15 of file SimHitPrinter.cc.

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

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

◆ ~SimHitPrinter()

SimHitPrinter::~SimHitPrinter ( )

Definition at line 28 of file SimHitPrinter.cc.

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

Member Function Documentation

◆ printEloss()

void SimHitPrinter::printEloss ( float  eloss) const

Definition at line 76 of file SimHitPrinter.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::G4cout.

76  {
77  G4cout << " Eloss: " << eloss << G4endl;
78  std::lock_guard<std::mutex> guard{fileMutex};
79  (*theFile) << " e " << eloss;
80 }

◆ printGlobal()

void SimHitPrinter::printGlobal ( GlobalPoint  global) const

Definition at line 94 of file SimHitPrinter.cc.

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

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

◆ printId()

void SimHitPrinter::printId ( int  id) const

Definition at line 52 of file SimHitPrinter.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::G4cout, and EcalPhiSymFlatTableProducers_cfi::id.

Referenced by MuonSensitiveDetector::saveHit().

52  {
53  G4cout << " Id: " << id << G4endl;
54  std::lock_guard<std::mutex> guard{fileMutex};
55  (*theFile) << " id ";
56  (*theFile).width(10);
57  (*theFile).setf(std::ios::right, std::ios::adjustfield);
58  (*theFile) << id;
59 }

◆ printLocal()

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

Definition at line 82 of file SimHitPrinter.cc.

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

Referenced by MuonSensitiveDetector::saveHit().

82  {
83  G4cout << " Local(en/ex): " << localen.x() << " " << localen.y() << " " << localen.z() << " / " << localex.x() << " "
84  << localex.y() << " " << localex.z() << G4endl;
85  std::lock_guard<std::mutex> guard{fileMutex};
86  (*theFile).width(10);
87  (*theFile).setf(std::ios::right, std::ios::adjustfield);
88  (*theFile).setf(std::ios::floatfield);
89  (*theFile).precision(6);
90  (*theFile) << " en/ex " << localen.x() << " " << localen.y() << " " << localen.z() << " / " << localex.x() << " "
91  << localex.y() << " " << localex.z();
92 }
T z() const
Definition: PV3DBase.h:61
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60

◆ printPabs()

void SimHitPrinter::printPabs ( float  pabs) const

Definition at line 70 of file SimHitPrinter.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::G4cout.

70  {
71  G4cout << " Pabs: " << pabs << G4endl;
72  std::lock_guard<std::mutex> guard{fileMutex};
73  (*theFile) << " p " << pabs;
74 }

◆ printTrack()

void SimHitPrinter::printTrack ( int  id) const

Definition at line 61 of file SimHitPrinter.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::G4cout, and EcalPhiSymFlatTableProducers_cfi::id.

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

61  {
62  G4cout << " Track: " << id << G4endl;
63  std::lock_guard<std::mutex> guard{fileMutex};
64  (*theFile) << " trk ";
65  (*theFile).width(10);
66  (*theFile).setf(std::ios::right, std::ios::adjustfield);
67  (*theFile) << id;
68 }

◆ startNewEvent()

void SimHitPrinter::startNewEvent ( int  num)

Definition at line 47 of file SimHitPrinter.cc.

References EgammaValidation_cff::num.

47  {
48  std::lock_guard<std::mutex> guard{fileMutex};
49  (*theFile) << "Event " << num << std::endl;
50 }

◆ startNewSimHit()

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

Definition at line 32 of file SimHitPrinter.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::G4cout, and alignCSCRings::s.

Referenced by MuonSensitiveDetector::saveHit().

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

Member Data Documentation

◆ theFile

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

Definition at line 39 of file SimHitPrinter.h.

Referenced by SimHitPrinter().