CMS 3D CMS Logo

Public Types | Public Member Functions | Static Public Attributes | Private Attributes

EcalTBCrystalMap Class Reference

#include <EcalTBCrystalMap.h>

List of all members.

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 19 of file EcalTBCrystalMap.h.


Member Typedef Documentation

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

Definition at line 23 of file EcalTBCrystalMap.h.


Constructor & Destructor Documentation

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

Definition at line 3 of file EcalTBCrystalMap.cc.

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

                                                                {
                                                                                                                                          
  // check if File exists
  std::ifstream * input= new std::ifstream(MapFileName.c_str(), std::ios::in);
  if(! (*input))
    {
      throw cms::Exception("FileNotFound", "Ecal TB Crystal map file not found") 
        <<  "\n" << MapFileName << " could not be opened.\n";
   }
  if (input){

    int nCrysCount = 0;

    while (nCrysCount <= NCRYSTAL ) {
      
      (*input) >> crysIndex >> crysEta >>  crysPhi;
      map_[std::pair<double,double>(crysEta,crysPhi)] = crysIndex;

      nCrysCount++;
      
    }

    input->close();
  }

}
EcalTBCrystalMap::~EcalTBCrystalMap ( )

Definition at line 30 of file EcalTBCrystalMap.cc.

                                    {
}

Member Function Documentation

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

Definition at line 33 of file EcalTBCrystalMap.cc.

References map_.

                                                                 {

  int thisCrysIndex = 0;

  CrystalTBIndexMap::const_iterator mapItr = map_.find(std::make_pair(thisEta,thisPhi));
  if ( mapItr != map_.end() ) {
    thisCrysIndex = mapItr->second;
  }

  return thisCrysIndex;

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

Definition at line 46 of file EcalTBCrystalMap.cc.

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

Referenced by EcalTBMCInfoProducer::EcalTBMCInfoProducer().

                                                                                                    {
  
  thisEta = thisPhi = 0.;

  if ( thisCrysIndex < 1 || thisCrysIndex > NCRYSTAL ) {
    edm::LogError("OutOfBounds") << "Required crystal number " << thisCrysIndex << " outside range";
    return;
  }

  for ( CrystalTBIndexMap::const_iterator mapItr = map_.begin() ; mapItr != map_.end() ; ++mapItr) {
    int theCrysIndex = mapItr->second;
    if ( theCrysIndex == thisCrysIndex ) {
      thisEta = (mapItr->first).first;
      thisPhi = (mapItr->first).second;
      return;
    }
  }

}

Member Data Documentation

double EcalTBCrystalMap::crysEta [private]

Definition at line 35 of file EcalTBCrystalMap.h.

Referenced by EcalTBCrystalMap().

Definition at line 36 of file EcalTBCrystalMap.h.

Referenced by EcalTBCrystalMap().

double EcalTBCrystalMap::crysPhi [private]

Definition at line 35 of file EcalTBCrystalMap.h.

Referenced by EcalTBCrystalMap().

Definition at line 38 of file EcalTBCrystalMap.h.

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

const int EcalTBCrystalMap::NCRYSTAL = 1700 [static]