Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:29

0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 #include "CondFormats/SiStripObjects/interface/SiStripSummary.h"
0003 #include "CommonTools/TrackerMap/interface/TmModule.h"
0004 #include "CondTools/SiStrip/interface/SiStripMiscalibrateHelper.h"
0005 #include "CondCore/SiStripPlugins/interface/SiStripPayloadInspectorHelper.h"
0006 
0007 /*--------------------------------------------------------------------*/
0008 sistripsummary::TrackerRegion SiStripMiscalibrate::getRegionFromString(std::string region)
0009 /*--------------------------------------------------------------------*/
0010 {
0011   std::map<std::string, sistripsummary::TrackerRegion> mapping = {
0012       {"Tracker", sistripsummary::TRACKER}, {"TIB", sistripsummary::TIB},       {"TIB_1", sistripsummary::TIB_1},
0013       {"TIB_2", sistripsummary::TIB_2},     {"TIB_3", sistripsummary::TIB_3},   {"TIB_4", sistripsummary::TIB_4},
0014       {"TID", sistripsummary::TID},         {"TIDP", sistripsummary::TIDP},     {"TIDP_1", sistripsummary::TIDP_1},
0015       {"TIDP_2", sistripsummary::TIDP_2},   {"TIDP_3", sistripsummary::TIDP_3}, {"TIDM", sistripsummary::TIDM},
0016       {"TIDM_1", sistripsummary::TIDM_1},   {"TIDM_2", sistripsummary::TIDM_2}, {"TIDM_3", sistripsummary::TIDM_3},
0017       {"TOB", sistripsummary::TOB},         {"TOB_1", sistripsummary::TOB_1},   {"TOB_2", sistripsummary::TOB_2},
0018       {"TOB_3", sistripsummary::TOB_3},     {"TOB_4", sistripsummary::TOB_4},   {"TOB_5", sistripsummary::TOB_5},
0019       {"TOB_6", sistripsummary::TOB_6},     {"TEC", sistripsummary::TEC},       {"TECP", sistripsummary::TECP},
0020       {"TECP_1", sistripsummary::TECP_1},   {"TECP_2", sistripsummary::TECP_2}, {"TECP_3", sistripsummary::TECP_3},
0021       {"TECP_4", sistripsummary::TECP_4},   {"TECP_5", sistripsummary::TECP_5}, {"TECP_6", sistripsummary::TECP_6},
0022       {"TECP_7", sistripsummary::TECP_7},   {"TECP_8", sistripsummary::TECP_8}, {"TECP_9", sistripsummary::TECP_9},
0023       {"TECM", sistripsummary::TECM},       {"TECM_1", sistripsummary::TECM_1}, {"TECM_2", sistripsummary::TECM_2},
0024       {"TECM_3", sistripsummary::TECM_3},   {"TECM_4", sistripsummary::TECM_4}, {"TECM_5", sistripsummary::TECM_5},
0025       {"TECM_6", sistripsummary::TECM_6},   {"TECM_7", sistripsummary::TECM_7}, {"TECM_8", sistripsummary::TECM_8},
0026       {"TECM_9", sistripsummary::TECM_9}};
0027 
0028   if (mapping.find(region) == mapping.end()) {
0029     edm::LogError("SiStripMiscalibrate") << "@SUB=analyze"
0030                                          << "Unknown partition: " << region;
0031     throw cms::Exception("Invalid Partition passed");
0032   } else {
0033     return mapping[region];
0034   }
0035 }
0036 
0037 /*--------------------------------------------------------------------*/
0038 std::vector<sistripsummary::TrackerRegion> SiStripMiscalibrate::getRegionsFromDetId(
0039     const TrackerTopology* m_trackerTopo, DetId detid)
0040 /*--------------------------------------------------------------------*/
0041 {
0042   int layer = 0;
0043   int side = 0;
0044   int subdet = 0;
0045   int detCode = 0;
0046 
0047   std::vector<sistripsummary::TrackerRegion> ret;
0048 
0049   switch (detid.subdetId()) {
0050     case StripSubdetector::TIB:
0051       layer = m_trackerTopo->tibLayer(detid);
0052       subdet = 1;
0053       break;
0054     case StripSubdetector::TOB:
0055       layer = m_trackerTopo->tobLayer(detid);
0056       subdet = 2;
0057       break;
0058     case StripSubdetector::TID:
0059       // is this module in TID+ or TID-?
0060       layer = m_trackerTopo->tidWheel(detid);
0061       side = m_trackerTopo->tidSide(detid);
0062       subdet = 3 * 10 + side;
0063       break;
0064     case StripSubdetector::TEC:
0065       // is this module in TEC+ or TEC-?
0066       layer = m_trackerTopo->tecWheel(detid);
0067       side = m_trackerTopo->tecSide(detid);
0068       subdet = 4 * 10 + side;
0069       break;
0070   }
0071 
0072   detCode = (subdet * 10) + layer;
0073 
0074   ret.push_back(static_cast<sistripsummary::TrackerRegion>(detCode));
0075 
0076   if (subdet / 10 > 0) {
0077     ret.push_back(static_cast<sistripsummary::TrackerRegion>(subdet / 10));
0078   }
0079 
0080   ret.push_back(static_cast<sistripsummary::TrackerRegion>(subdet));
0081   ret.push_back(sistripsummary::TRACKER);
0082 
0083   return ret;
0084 }
0085 
0086 /*--------------------------------------------------------------------*/
0087 std::pair<float, float> SiStripMiscalibrate::getTruncatedRange(const TrackerMap* theMap) {
0088   /*--------------------------------------------------------------------*/
0089 
0090   // ------------ trim the tracker map  ------------
0091 
0092   auto map = theMap->smoduleMap;
0093   std::map<unsigned int, float> info_per_detid;
0094   for (int layer = 1; layer < 44; layer++) {
0095     for (int ring = theMap->firstRing[layer - 1]; ring < theMap->ntotRing[layer - 1] + theMap->firstRing[layer - 1];
0096          ring++) {
0097       for (int module = 1; module < 200; module++) {
0098         int key = layer * 100000 + ring * 1000 + module;
0099         TmModule* mod = map[key];
0100         if (mod != nullptr && !mod->notInUse() && mod->count > 0) {
0101           info_per_detid[key] = mod->value;
0102         }
0103       }  // loop on modules
0104     }    // loop on ring
0105   }      // loop on layers
0106 
0107   auto range = SiStripPI::getTheRange(info_per_detid, 2);
0108   return range;
0109 }