src
SimMuon
Neutron
src
AsciiNeutronReader.cc
Go to the documentation of this file.
1
#include "
SimMuon/Neutron/src/AsciiNeutronReader.h
"
2
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
3
#include "
FWCore/Utilities/interface/EDMException.h
"
4
#include "
FWCore/ParameterSet/interface/FileInPath.h
"
5
#include <sstream>
6
#include <iostream>
7
8
using namespace
std
;
9
10
AsciiNeutronReader::AsciiNeutronReader
(
string
fileNameBase)
11
: theFileNameBase(fileNameBase),
12
//theStreamPos(nChamberTypes+1, 0) //TODO WON"T WORK! replace with a map
13
theStreamPos(11, 0) {}
14
15
void
AsciiNeutronReader::readNextEvent
(
int
chamberType
,
edm::PSimHitContainer
&
result
) {
16
stringstream
fileName
;
17
fileName
<<
theFileNameBase
<<
chamberType
;
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
23
int
nhits
=
read_nhits
(
fin
,
chamberType
);
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
}
38
39
int
AsciiNeutronReader::read_nhits
(ifstream&
fin
,
int
chamberType
) {
40
int
nhits
= 0;
41
// go to the last saved place
42
fin
.seekg(
theStreamPos
[
chamberType
]);
43
if
(
fin
.eof()) {
44
resetStreampos
(
fin
,
chamberType
);
45
}
46
LogDebug
(
"NeutronReader"
) <<
"starting from pos "
<<
theStreamPos
[
chamberType
] <<
" EOF "
<<
fin
.eof();
47
fin
>>
nhits
;
48
if
(
fin
.eof()) {
49
resetStreampos
(
fin
,
chamberType
);
50
fin
>>
nhits
;
51
}
52
LogDebug
(
"NeutronReader"
) <<
"returning nhits "
<<
nhits
;
53
return
nhits
;
54
}
55
56
void
AsciiNeutronReader::resetStreampos
(ifstream&
fin
,
int
chamberType
) {
57
LogDebug
(
"NeutronReader"
) <<
"reached EOF, resetting streampos "
;
58
theStreamPos
[
chamberType
] = 0;
59
fin
.clear();
60
fin
.seekg(0, ios::beg);
61
}
AsciiNeutronReader::readNextEvent
void readNextEvent(int chamberType, edm::PSimHitContainer &result) override
Definition:
AsciiNeutronReader.cc:15
Exception
Definition:
hltDiff.cc:245
MessageLogger.h
mps_fire.result
result
Definition:
mps_fire.py:311
std
Definition:
JetResolutionObject.h:76
recoMuon::in
Definition:
RecoMuonEnumerators.h:6
type
type
Definition:
SiPixelVCal_PayloadInspector.cc:39
groupFilesInBlocks.fin
fin
Definition:
groupFilesInBlocks.py:94
DDAxes::phi
FileInPath.h
mps_splice.entry
entry
Definition:
mps_splice.py:68
EDMException.h
gainCalibHelper::gainCalibPI::type
type
Definition:
SiPixelGainCalibHelper.h:40
AsciiNeutronReader.h
nano_mu_digi_cff.chamberType
chamberType
Definition:
nano_mu_digi_cff.py:92
AsciiNeutronReader::theFileNameBase
std::string theFileNameBase
Definition:
AsciiNeutronReader.h:27
nano_mu_digi_cff.layer
layer
Definition:
nano_mu_digi_cff.py:27
AsciiNeutronReader::theStreamPos
std::vector< std::streampos > theStreamPos
Definition:
AsciiNeutronReader.h:28
AsciiNeutronReader::AsciiNeutronReader
AsciiNeutronReader(std::string fileNameBase)
Definition:
AsciiNeutronReader.cc:10
Point3DBase< float, LocalTag >
MillePedeFileConverter_cfg.fileName
fileName
Definition:
MillePedeFileConverter_cfg.py:32
PSimHit
Definition:
PSimHit.h:15
HLT_2024v10_cff.track
track
Definition:
HLT_2024v10_cff.py:9662
TrackingDataMCValidation_Standalone_cff.nhits
nhits
Definition:
TrackingDataMCValidation_Standalone_cff.py:40
edm::PSimHitContainer
std::vector< PSimHit > PSimHitContainer
Definition:
PSimHitContainer.h:11
AsciiNeutronReader::read_nhits
int read_nhits(std::ifstream &fin, int chamberType)
Definition:
AsciiNeutronReader.cc:39
AsciiNeutronReader::resetStreampos
void resetStreampos(std::ifstream &fin, int chamberType)
Definition:
AsciiNeutronReader.cc:56
theta
Geom::Theta< T > theta() const
Definition:
Basic3DVectorLD.h:153
AlCaHLTBitMon_ParallelJobs.p
def p
Definition:
AlCaHLTBitMon_ParallelJobs.py:153
LogDebug
#define LogDebug(id)
Definition:
MessageLogger.h:241
beamvalidation.exit
def exit(msg="")
Definition:
beamvalidation.py:52
Generated for CMSSW Reference Manual by
1.8.14