CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Attributes | Private Attributes
EcalTBCrystalMap Class Reference

#include <EcalTBCrystalMap.h>

Public Types

typedef std::map< std::pair< double, double >, int > CrystalTBIndexMap
 

Public Member Functions

int CrystalIndex (double thisEta, double thisPhi)
 
 EcalTBCrystalMap (std::string const &MapFileName)
 
void findCrystalAngles (const int thisCrysIndex, double &thisEta, double &thisPhi)
 
 ~EcalTBCrystalMap ()
 

Static Public Attributes

static const int NCRYSTAL = 1700
 

Private Attributes

double crysEta
 
int crysIndex
 
double crysPhi
 
CrystalTBIndexMap map_
 

Detailed Description

Definition at line 17 of file EcalTBCrystalMap.h.

Member Typedef Documentation

◆ CrystalTBIndexMap

typedef std::map<std::pair<double, double>, int> EcalTBCrystalMap::CrystalTBIndexMap

Definition at line 19 of file EcalTBCrystalMap.h.

Constructor & Destructor Documentation

◆ EcalTBCrystalMap()

EcalTBCrystalMap::EcalTBCrystalMap ( std::string const &  MapFileName)

Definition at line 3 of file EcalTBCrystalMap.cc.

References crysEta, crysIndex, crysPhi, Exception, recoMuon::in, input, map_, and NCRYSTAL.

3  {
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 }
CrystalTBIndexMap map_
static const int NCRYSTAL
static std::string const input
Definition: EdmProvDump.cc:47

◆ ~EcalTBCrystalMap()

EcalTBCrystalMap::~EcalTBCrystalMap ( )

Definition at line 25 of file EcalTBCrystalMap.cc.

25 {}

Member Function Documentation

◆ CrystalIndex()

int EcalTBCrystalMap::CrystalIndex ( double  thisEta,
double  thisPhi 
)

Definition at line 27 of file EcalTBCrystalMap.cc.

References map_.

27  {
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 }
CrystalTBIndexMap map_

◆ findCrystalAngles()

void EcalTBCrystalMap::findCrystalAngles ( const int  thisCrysIndex,
double &  thisEta,
double &  thisPhi 
)

Definition at line 38 of file EcalTBCrystalMap.cc.

References first, map_, NCRYSTAL, and edm::second().

38  {
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 }
CrystalTBIndexMap map_
static const int NCRYSTAL
Log< level::Error, false > LogError
U second(std::pair< T, U > const &p)

Member Data Documentation

◆ crysEta

double EcalTBCrystalMap::crysEta
private

Definition at line 30 of file EcalTBCrystalMap.h.

Referenced by EcalTBCrystalMap().

◆ crysIndex

int EcalTBCrystalMap::crysIndex
private

Definition at line 31 of file EcalTBCrystalMap.h.

Referenced by EcalTBCrystalMap().

◆ crysPhi

double EcalTBCrystalMap::crysPhi
private

Definition at line 30 of file EcalTBCrystalMap.h.

Referenced by EcalTBCrystalMap().

◆ map_

CrystalTBIndexMap EcalTBCrystalMap::map_
private

Definition at line 33 of file EcalTBCrystalMap.h.

Referenced by CrystalIndex(), EcalTBCrystalMap(), and findCrystalAngles().

◆ NCRYSTAL

const int EcalTBCrystalMap::NCRYSTAL = 1700
static