CMS 3D CMS Logo

EcalTBCrystalMap.cc
Go to the documentation of this file.
2 
4  // check if File exists
5  std::ifstream* input = new std::ifstream(MapFileName.c_str(), std::ios::in);
6  if (!(*input)) {
7  throw cms::Exception("FileNotFound", "Ecal TB Crystal map file not found")
8  << "\n"
9  << MapFileName << " could not be opened.\n";
10  }
11  if (input) {
12  int nCrysCount = 0;
13 
14  while (nCrysCount <= NCRYSTAL) {
15  (*input) >> crysIndex >> crysEta >> crysPhi;
16  map_[std::pair<double, double>(crysEta, crysPhi)] = crysIndex;
17 
18  nCrysCount++;
19  }
20 
21  input->close();
22  }
23 }
24 
26 
27 int EcalTBCrystalMap::CrystalIndex(double thisEta, double thisPhi) {
28  int thisCrysIndex = 0;
29 
30  CrystalTBIndexMap::const_iterator mapItr = map_.find(std::make_pair(thisEta, thisPhi));
31  if (mapItr != map_.end()) {
32  thisCrysIndex = mapItr->second;
33  }
34 
35  return thisCrysIndex;
36 }
37 
38 void EcalTBCrystalMap::findCrystalAngles(const int thisCrysIndex, double& thisEta, double& thisPhi) {
39  thisEta = thisPhi = 0.;
40 
41  if (thisCrysIndex < 1 || thisCrysIndex > NCRYSTAL) {
42  edm::LogError("OutOfBounds") << "Required crystal number " << thisCrysIndex << " outside range";
43  return;
44  }
45 
46  for (CrystalTBIndexMap::const_iterator mapItr = map_.begin(); mapItr != map_.end(); ++mapItr) {
47  int theCrysIndex = mapItr->second;
48  if (theCrysIndex == thisCrysIndex) {
49  thisEta = (mapItr->first).first;
50  thisPhi = (mapItr->first).second;
51  return;
52  }
53  }
54 }
input
static const std::string input
Definition: EdmProvDump.cc:48
EcalTBCrystalMap::findCrystalAngles
void findCrystalAngles(const int thisCrysIndex, double &thisEta, double &thisPhi)
Definition: EcalTBCrystalMap.cc:38
EcalTBCrystalMap::crysPhi
double crysPhi
Definition: EcalTBCrystalMap.h:30
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
EcalTBCrystalMap::crysEta
double crysEta
Definition: EcalTBCrystalMap.h:30
EcalTBCrystalMap::map_
CrystalTBIndexMap map_
Definition: EcalTBCrystalMap.h:33
EcalTBCrystalMap::EcalTBCrystalMap
EcalTBCrystalMap(std::string const &MapFileName)
Definition: EcalTBCrystalMap.cc:3
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
EcalTBCrystalMap::~EcalTBCrystalMap
~EcalTBCrystalMap()
Definition: EcalTBCrystalMap.cc:25
EcalTBCrystalMap::crysIndex
int crysIndex
Definition: EcalTBCrystalMap.h:31
recoMuon::in
Definition: RecoMuonEnumerators.h:6
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalTBCrystalMap::CrystalIndex
int CrystalIndex(double thisEta, double thisPhi)
Definition: EcalTBCrystalMap.cc:27
EcalTBCrystalMap.h
EcalTBCrystalMap::NCRYSTAL
static const int NCRYSTAL
Definition: EcalTBCrystalMap.h:27
Exception
Definition: hltDiff.cc:245