CMS 3D CMS Logo

AsciiNeutronReader Class Reference

This reads patterns of neutron hits in muon chambers from an ASCII database, so they can be superimposed onto signal events. More...

#include <SimMuon/Neutron/src/AsciiNeutronReader.h>

Inheritance diagram for AsciiNeutronReader:

NeutronReader

List of all members.

Public Member Functions

 AsciiNeutronReader (std::string fileNameBase)
virtual void readNextEvent (int chamberType, edm::PSimHitContainer &result)

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  ) 


Member Function Documentation

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

Referenced by readNextEvent().

void AsciiNeutronReader::readNextEvent ( int  chamberType,
edm::PSimHitContainer result 
) [virtual]

Implements NeutronReader.

Definition at line 18 of file AsciiNeutronReader.cc.

References Exception, cmsRelvalreport::exit, aod_PYTHIA_cfg::fileName, in, p, phi, read_nhits(), theFileNameBase, theStreamPos, theta, and track.

00018                                                                                     {
00019   stringstream fileName;
00020   fileName << theFileNameBase << chamberType;
00021   ifstream fin(fileName.str().c_str(), ios::in);
00022   if(!fin.is_open()) {
00023     throw cms::Exception("NeutronReader") 
00024       << "Muon neutron noise file missing " << fileName.str();
00025   }
00026 
00027   int nhits = read_nhits(fin, chamberType);
00028   for(int ihit = 0; ihit < nhits; ++ihit) {
00029     float entryX, entryY, entryZ, exitX, exitY, exitZ;
00030     float p, tof, eloss, theta, phi;
00031     int type, layer, track;
00032 
00033     fin >> entryX >> entryY >> entryZ
00034         >> exitX  >> exitY  >> exitZ
00035         >> p >> tof >> eloss >> type >> layer >> track >> theta >> phi;
00036     LocalPoint entry(entryX, entryY, entryZ);
00037     LocalPoint exit (exitX,  exitY,  exitZ);
00038     PSimHit phit(entry, exit, p, tof, eloss, type, layer, track, theta, phi);
00039     result.push_back(phit);
00040   }
00041   theStreamPos[chamberType] = fin.tellg();
00042 }

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


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 readNextEvent().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:14:49 2009 for CMSSW by  doxygen 1.5.4