Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:30

0001 #include "CondFormats/SiPhase2TrackerObjects/interface/SiPhase2OuterTrackerLorentzAngle.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 
0004 bool SiPhase2OuterTrackerLorentzAngle::putLorentzAngle(const uint32_t& detid, float value) {
0005   std::unordered_map<unsigned int, float>::const_iterator id = m_LA.find(detid);
0006   if (id != m_LA.end()) {
0007     edm::LogError("SiPhase2OuterTrackerLorentzAngle") << "SiPhase2OuterTrackerLorentzAngle for DetID " << detid
0008                                                       << " is already stored. Skipping this put" << std::endl;
0009     return false;
0010   } else
0011     m_LA[detid] = value;
0012   return true;
0013 }
0014 
0015 float SiPhase2OuterTrackerLorentzAngle::getLorentzAngle(const uint32_t& detid) const {
0016   std::unordered_map<unsigned int, float>::const_iterator id = m_LA.find(detid);
0017   if (id != m_LA.end())
0018     return id->second;
0019   else {
0020     throw cms::Exception("SiPhase2OuterTrackerLorentzAngle")
0021         << "SiPhase2OuterTrackerLorentzAngle for DetID " << detid << " is not stored" << std::endl;
0022   }
0023 }
0024 
0025 void SiPhase2OuterTrackerLorentzAngle::getLorentzAnglesByModuleType(const TrackerGeometry* trackerGeometry,
0026                                                                     const TrackerGeometry::ModuleType& theType,
0027                                                                     std::unordered_map<unsigned int, float>& out) const {
0028   for (const auto& [det, LA] : m_LA) {
0029     if (trackerGeometry->getDetectorType(det) == theType) {
0030       out[det] = LA;
0031     }
0032   }
0033 }
0034 
0035 void SiPhase2OuterTrackerLorentzAngle::printDebug(std::stringstream& ss, const TrackerTopology* /*trackerTopo*/) const {
0036   const std::unordered_map<unsigned int, float>& detid_la = getLorentzAngles();
0037   ss << "SiPhase2OuterTrackerLorentzAngleReader:" << std::endl;
0038   ss << "detid \t Lorentz angle" << std::endl;
0039   for (const auto& it : detid_la) {
0040     ss << it.first << "\t" << it.second << std::endl;
0041   }
0042 }