CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
AsciiNeutronReader Class Reference

#include <AsciiNeutronReader.h>

Inheritance diagram for AsciiNeutronReader:
NeutronReader

Public Member Functions

 AsciiNeutronReader (std::string fileNameBase)
 
void readNextEvent (int chamberType, edm::PSimHitContainer &result) override
 
- Public Member Functions inherited from NeutronReader
 NeutronReader ()
 
virtual ~NeutronReader ()
 

Private Member Functions

int read_nhits (std::ifstream &fin, int chamberType)
 
void resetStreampos (std::ifstream &fin, int chamberType)
 

Private Attributes

std::string theFileNameBase
 
std::vector< std::streampos > theStreamPos
 

Detailed Description

This reads patterns of neutron hits in muon chambers from an ASCII database, so they can be superimposed onto signal events. It reads the events sequentially, and loops back to the beginning when it reaches EOF

Definition at line 17 of file AsciiNeutronReader.h.

Constructor & Destructor Documentation

◆ AsciiNeutronReader()

AsciiNeutronReader::AsciiNeutronReader ( std::string  fileNameBase)

Definition at line 10 of file AsciiNeutronReader.cc.

11  : theFileNameBase(fileNameBase),
12  //theStreamPos(nChamberTypes+1, 0) //TODO WON"T WORK! replace with a map
13  theStreamPos(11, 0) {}
std::string theFileNameBase
std::vector< std::streampos > theStreamPos

Member Function Documentation

◆ read_nhits()

int AsciiNeutronReader::read_nhits ( std::ifstream &  fin,
int  chamberType 
)
private

Definition at line 39 of file AsciiNeutronReader.cc.

References nano_mu_digi_cff::chamberType, groupFilesInBlocks::fin, LogDebug, nhits, resetStreampos(), and theStreamPos.

Referenced by readNextEvent().

39  {
40  int nhits = 0;
41  // go to the last saved place
43  if (fin.eof()) {
45  }
46  LogDebug("NeutronReader") << "starting from pos " << theStreamPos[chamberType] << " EOF " << fin.eof();
47  fin >> nhits;
48  if (fin.eof()) {
50  fin >> nhits;
51  }
52  LogDebug("NeutronReader") << "returning nhits " << nhits;
53  return nhits;
54 }
std::vector< std::streampos > theStreamPos
void resetStreampos(std::ifstream &fin, int chamberType)
#define LogDebug(id)

◆ readNextEvent()

void AsciiNeutronReader::readNextEvent ( int  chamberType,
edm::PSimHitContainer result 
)
overridevirtual

Implements NeutronReader.

Definition at line 15 of file AsciiNeutronReader.cc.

References nano_mu_digi_cff::chamberType, mps_splice::entry, Exception, beamvalidation::exit(), MillePedeFileConverter_cfg::fileName, groupFilesInBlocks::fin, recoMuon::in, nano_mu_digi_cff::layer, nhits, AlCaHLTBitMon_ParallelJobs::p, phi, read_nhits(), mps_fire::result, theFileNameBase, theStreamPos, theta(), and HLT_2024v11_cff::track.

15  {
16  stringstream fileName;
18  ifstream fin(fileName.str().c_str(), ios::in);
19  if (!fin.is_open()) {
20  throw cms::Exception("NeutronReader") << "Muon neutron noise file missing " << fileName.str();
21  }
22 
24  for (int ihit = 0; ihit < nhits; ++ihit) {
25  float entryX, entryY, entryZ, exitX, exitY, exitZ;
26  float p, tof, eloss, theta, phi;
27  int type, layer, track;
28 
29  fin >> entryX >> entryY >> entryZ >> exitX >> exitY >> exitZ >> p >> tof >> eloss >> type >> layer >> track >>
30  theta >> phi;
31  LocalPoint entry(entryX, entryY, entryZ);
32  LocalPoint exit(exitX, exitY, exitZ);
33  PSimHit phit(entry, exit, p, tof, eloss, type, layer, track, theta, phi);
34  result.push_back(phit);
35  }
36  theStreamPos[chamberType] = fin.tellg();
37 }
std::string theFileNameBase
std::vector< std::streampos > theStreamPos
int read_nhits(std::ifstream &fin, int chamberType)
Geom::Theta< T > theta() const
def exit(msg="")

◆ resetStreampos()

void AsciiNeutronReader::resetStreampos ( std::ifstream &  fin,
int  chamberType 
)
private

Definition at line 56 of file AsciiNeutronReader.cc.

References nano_mu_digi_cff::chamberType, groupFilesInBlocks::fin, LogDebug, and theStreamPos.

Referenced by read_nhits().

56  {
57  LogDebug("NeutronReader") << "reached EOF, resetting streampos ";
59  fin.clear();
60  fin.seekg(0, ios::beg);
61 }
std::vector< std::streampos > theStreamPos
#define LogDebug(id)

Member Data Documentation

◆ theFileNameBase

std::string AsciiNeutronReader::theFileNameBase
private

Definition at line 27 of file AsciiNeutronReader.h.

Referenced by readNextEvent().

◆ theStreamPos

std::vector<std::streampos> AsciiNeutronReader::theStreamPos
private

Definition at line 28 of file AsciiNeutronReader.h.

Referenced by read_nhits(), readNextEvent(), and resetStreampos().