CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
virtual void readNextEvent (int chamberType, edm::PSimHitContainer &result)
 
- 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 ( std::string  fileNameBase)

Definition at line 10 of file AsciiNeutronReader.cc.

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

Member Function Documentation

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

Definition at line 45 of file AsciiNeutronReader.cc.

References LogDebug, resetStreampos(), and theStreamPos.

Referenced by readNextEvent().

45  {
46  int nhits = 0;
47  // go to the last saved place
48  fin.seekg(theStreamPos[chamberType]);
49  if(fin.eof()) {
50  resetStreampos(fin, chamberType);
51  }
52  LogDebug("NeutronReader") << "starting from pos " << theStreamPos[chamberType]
53  << " EOF " << fin.eof();
54  fin >> nhits;
55  if(fin.eof()) {
56  resetStreampos(fin, chamberType);
57  fin >> nhits;
58  }
59  LogDebug("NeutronReader") << "returning nhits " << nhits;
60  return nhits;
61 }
#define LogDebug(id)
std::vector< std::streampos > theStreamPos
void resetStreampos(std::ifstream &fin, int chamberType)
void AsciiNeutronReader::readNextEvent ( int  chamberType,
edm::PSimHitContainer result 
)
virtual

Implements NeutronReader.

Definition at line 18 of file AsciiNeutronReader.cc.

References edm::hlt::Exception, cmsRelvalreport::exit, convertXMLtoSQLite_cfg::fileName, groupFilesInBlocks::fin, recoMuon::in, AlCaHLTBitMon_ParallelJobs::p, phi, read_nhits(), theFileNameBase, theStreamPos, and theta().

18  {
19  stringstream fileName;
20  fileName << theFileNameBase << chamberType;
21  ifstream fin(fileName.str().c_str(), ios::in);
22  if(!fin.is_open()) {
23  throw cms::Exception("NeutronReader")
24  << "Muon neutron noise file missing " << fileName.str();
25  }
26 
27  int nhits = read_nhits(fin, chamberType);
28  for(int ihit = 0; ihit < nhits; ++ihit) {
29  float entryX, entryY, entryZ, exitX, exitY, exitZ;
30  float p, tof, eloss, theta, phi;
31  int type, layer, track;
32 
33  fin >> entryX >> entryY >> entryZ
34  >> exitX >> exitY >> exitZ
35  >> p >> tof >> eloss >> type >> layer >> track >> theta >> phi;
36  LocalPoint entry(entryX, entryY, entryZ);
37  LocalPoint exit (exitX, exitY, exitZ);
38  PSimHit phit(entry, exit, p, tof, eloss, type, layer, track, theta, phi);
39  result.push_back(phit);
40  }
41  theStreamPos[chamberType] = fin.tellg();
42 }
type
Definition: HCALResponse.h:22
Geom::Theta< T > theta() const
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
tuple result
Definition: query.py:137
std::string theFileNameBase
std::vector< std::streampos > theStreamPos
int read_nhits(std::ifstream &fin, int chamberType)
Definition: DDAxes.h:10
void AsciiNeutronReader::resetStreampos ( std::ifstream &  fin,
int  chamberType 
)
private

Definition at line 64 of file AsciiNeutronReader.cc.

References LogDebug, and theStreamPos.

Referenced by read_nhits().

64  {
65  LogDebug("NeutronReader") << "reached EOF, resetting streampos ";
66  theStreamPos[chamberType] = 0;
67  fin.clear();
68  fin.seekg(0, ios::beg);
69 }
#define LogDebug(id)
std::vector< std::streampos > theStreamPos

Member Data Documentation

std::string AsciiNeutronReader::theFileNameBase
private

Definition at line 29 of file AsciiNeutronReader.h.

Referenced by readNextEvent().

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

Definition at line 30 of file AsciiNeutronReader.h.

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