Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:08

0001 #include "DataFormats/ForwardDetId/interface/HGCSiliconDetIdToROC.h"
0002 
0003 HGCSiliconDetIdToROC::HGCSiliconDetIdToROC() {
0004   const int rocMax(6), cellRows(4), cellColumn(2);
0005   const int type[rocMax] = {0, 0, 1, 1, 2, 2};
0006   const int start1[rocMax][cellColumn] = {{3, 2}, {1, 0}, {1, 2}, {3, 4}, {7, 6}, {5, 4}};
0007   const int start2[rocMax] = {0, 0, 0, 1, 4, 4};
0008 
0009   // key = ROC #; value = vector of trigger cell U.V
0010   for (int roc = 0; roc < rocMax; ++roc) {
0011     std::vector<std::pair<int, int> > cells;
0012     if (type[roc] == 1) {
0013       for (int i1 = 0; i1 < cellColumn; ++i1) {
0014         int u = start1[roc][i1];
0015         int v = start2[roc] + u / 2;
0016         for (int i2 = 0; i2 < cellRows; ++i2) {
0017           cells.emplace_back(u, v);
0018           ++u;
0019         }
0020       }
0021     } else if (type[roc] == 2) {
0022       for (int i1 = 0; i1 < cellColumn; ++i1) {
0023         int v = start2[roc];
0024         int u = start1[roc][i1];
0025         for (int i2 = 0; i2 < cellRows; ++i2) {
0026           cells.emplace_back(u, v);
0027           ++v;
0028         }
0029       }
0030     } else {
0031       for (int i1 = 0; i1 < cellColumn; ++i1) {
0032         int u = start2[roc];
0033         int v = start1[roc][i1];
0034         for (int i2 = 0; i2 < cellRows; ++i2) {
0035           cells.emplace_back(u, v);
0036           ++u;
0037           ++v;
0038         }
0039       }
0040     }
0041     triggerIdFromROC_[roc + 1] = cells;
0042   }
0043 
0044   // key = trigger cell U,V; value = roc #
0045   for (auto const& itr : triggerIdFromROC_) {
0046     for (auto cell : itr.second)
0047       triggerIdToROC_[cell] = itr.first;
0048   }
0049 }
0050 
0051 int HGCSiliconDetIdToROC::getROCNumber(int triggerCellU, int triggerCellV, int type) const {
0052   auto itr = triggerIdToROC_.find(std::make_pair(triggerCellU, triggerCellV));
0053   int roc = ((itr == triggerIdToROC_.end()) ? -1 : ((type == 0) ? itr->second : (1 + itr->second) / 2));
0054   return roc;
0055 }
0056 
0057 std::vector<std::pair<int, int> > HGCSiliconDetIdToROC::getTriggerId(int roc, int type) const {
0058   std::vector<std::pair<int, int> > list;
0059   if (type == 0) {
0060     auto itr = triggerIdFromROC_.find(roc);
0061     return ((itr == triggerIdFromROC_.end()) ? list : itr->second);
0062   } else {
0063     for (int k = 0; k < 2; ++k) {
0064       int rocx = 2 * roc + k - 1;
0065       auto itr = triggerIdFromROC_.find(rocx);
0066       if (itr != triggerIdFromROC_.end()) {
0067         for (auto cell : itr->second)
0068           list.emplace_back(cell);
0069       }
0070     }
0071     return list;
0072   }
0073 }
0074 
0075 void HGCSiliconDetIdToROC::print() const {
0076   for (auto const& itr : triggerIdFromROC_) {
0077     std::cout << "ROC " << itr.first << " with " << (itr.second).size() << " trigger cells:";
0078     for (auto cell : itr.second)
0079       std::cout << " (" << cell.first << "," << cell.second << ")";
0080     std::cout << std::endl;
0081   }
0082   for (auto const& itr : triggerIdToROC_)
0083     std::cout << "Trigger cell (" << (itr.first).first << "," << (itr.first).second << ") : ROC " << itr.second
0084               << std::endl;
0085 }