CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalTBCrystalMap.cc
Go to the documentation of this file.
2 
4 
5  // check if File exists
6  std::ifstream * input= new std::ifstream(MapFileName.c_str(), std::ios::in);
7  if(! (*input))
8  {
9  throw cms::Exception("FileNotFound", "Ecal TB Crystal map file not found")
10  << "\n" << MapFileName << " could not be opened.\n";
11  }
12  if (input){
13 
14  int nCrysCount = 0;
15 
16  while (nCrysCount <= NCRYSTAL ) {
17 
18  (*input) >> crysIndex >> crysEta >> crysPhi;
19  map_[std::pair<double,double>(crysEta,crysPhi)] = crysIndex;
20 
21  nCrysCount++;
22 
23  }
24 
25  input->close();
26  }
27 
28 }
29 
31 }
32 
33 int EcalTBCrystalMap::CrystalIndex(double thisEta, double thisPhi) {
34 
35  int thisCrysIndex = 0;
36 
37  CrystalTBIndexMap::const_iterator mapItr = map_.find(std::make_pair(thisEta,thisPhi));
38  if ( mapItr != map_.end() ) {
39  thisCrysIndex = mapItr->second;
40  }
41 
42  return thisCrysIndex;
43 
44 }
45 
46 void EcalTBCrystalMap::findCrystalAngles(const int thisCrysIndex, double & thisEta, double & thisPhi) {
47 
48  thisEta = thisPhi = 0.;
49 
50  if ( thisCrysIndex < 1 || thisCrysIndex > NCRYSTAL ) {
51  edm::LogError("OutOfBounds") << "Required crystal number " << thisCrysIndex << " outside range";
52  return;
53  }
54 
55  for ( CrystalTBIndexMap::const_iterator mapItr = map_.begin() ; mapItr != map_.end() ; ++mapItr) {
56  int theCrysIndex = mapItr->second;
57  if ( theCrysIndex == thisCrysIndex ) {
58  thisEta = (mapItr->first).first;
59  thisPhi = (mapItr->first).second;
60  return;
61  }
62  }
63 
64 }
CrystalTBIndexMap map_
static const int NCRYSTAL
U second(std::pair< T, U > const &p)
EcalTBCrystalMap(std::string const &MapFileName)
bool first
Definition: L1TdeRCT.cc:94
void findCrystalAngles(const int thisCrysIndex, double &thisEta, double &thisPhi)
int CrystalIndex(double thisEta, double thisPhi)