Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-16 23:05:20

0001 // -*- C++ -*-
0002 //
0003 // Package:     HcalTestBeam
0004 // Class  :     HcalTBNumberingScheme
0005 //
0006 // Implementation:
0007 //     Numbering scheme for test beam hadron calorimeter
0008 //
0009 // Original Author:
0010 //         Created:  Tue May 16 10:14:34 CEST 2006
0011 //
0012 
0013 // system include files
0014 #include <iostream>
0015 
0016 // user include files
0017 #include "SimG4CMS/Calo/interface/HcalTestNumberingScheme.h"
0018 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
0019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0020 #include "SimG4CMS/HcalTestBeam/interface/HcalTBNumberingScheme.h"
0021 
0022 //#define EDM_ML_DEBUG
0023 //
0024 // member functions
0025 //
0026 
0027 uint32_t HcalTBNumberingScheme::getUnitID(const uint32_t idHit, const int mode) {
0028   int subdet, zside, group, ieta, iphi, lay;
0029   HcalTestNumbering::unpackHcalIndex(idHit, subdet, zside, group, ieta, iphi, lay);
0030 #ifdef EDM_ML_DEBUG
0031   edm::LogVerbatim("HcalTBSim") << "HcalTBNumberingScheme: i/p ID 0x" << std::hex << idHit << std::dec << " det "
0032                                 << zside << " group " << group << " layer " << lay << " eta " << ieta << " phi "
0033                                 << iphi;
0034 #endif
0035   uint32_t idunit;
0036   if (subdet == static_cast<int>(HcalBarrel)) {
0037     if (lay <= 17)
0038       group = 1;
0039     else
0040       group = 2;
0041   }
0042   if (mode > 0) {
0043     if (subdet == static_cast<int>(HcalBarrel) && iphi > 4) {
0044       if (lay <= 17) {
0045         // HB2 (unmasked and masked)
0046         if (ieta > 4 && ieta < 10) {
0047           idunit = HcalTestNumbering::packHcalIndex(0, 0, 1, 0, iphi, lay);
0048         } else {
0049           idunit = HcalTestNumbering::packHcalIndex(0, 0, 1, ieta, iphi, group);
0050         }
0051       } else {
0052         // HO behind HB2
0053         idunit = HcalTestNumbering::packHcalIndex(0, 0, 1, ieta, iphi, 18);
0054       }
0055     } else {
0056       // HB1, HE, HO behind HB1
0057       idunit = HcalTestNumbering::packHcalIndex(0, 0, 1, ieta, iphi, group);
0058     }
0059   } else {
0060     idunit = HcalTestNumbering::packHcalIndex(0, 0, 1, ieta, iphi, group);
0061   }
0062 
0063   HcalTestNumbering::unpackHcalIndex(idunit, subdet, zside, group, ieta, iphi, lay);
0064 #ifdef EDM_ML_DEBUG
0065   edm::LogVerbatim("HcalTBSim") << "HcalTBNumberingScheme: idHit 0x" << std::hex << idHit << " idunit 0x" << idunit
0066                                 << std::dec << "\n"
0067                                 << "HcalTBNumberingScheme: o/p ID 0x" << std::hex << idunit << std::dec << " det "
0068                                 << zside << " group " << group << " layer " << lay << " eta " << ieta << " phi "
0069                                 << iphi;
0070 #endif
0071   return idunit;
0072 }
0073 
0074 std::vector<uint32_t> HcalTBNumberingScheme::getUnitIDs(const int type, const int mode) {
0075   std::vector<uint32_t> tmp;
0076   int iphi, ieta, lay;
0077   uint32_t id;
0078 
0079   if (type != 1) {
0080     // Include HB and HO id's
0081     if (mode > 0) {
0082       // HB1 and masked part of HB2
0083       for (ieta = 1; ieta < 17; ieta++) {
0084         for (iphi = 1; iphi < 9; iphi++) {
0085           id = HcalTestNumbering::packHcalIndex(0, 0, 1, ieta, iphi, 1);
0086           tmp.push_back(id);
0087         }
0088       }
0089       // HO behind HB1
0090       for (ieta = 1; ieta < 16; ieta++) {
0091         for (iphi = 2; iphi < 5; iphi++) {
0092           id = HcalTestNumbering::packHcalIndex(0, 0, 1, ieta, iphi, 2);
0093           tmp.push_back(id);
0094         }
0095       }
0096       // HB2
0097       for (lay = 1; lay < 18; lay++) {
0098         for (iphi = 5; iphi < 9; iphi++) {
0099           id = HcalTestNumbering::packHcalIndex(0, 0, 1, 0, iphi, lay);
0100           tmp.push_back(id);
0101         }
0102       }
0103       // HO behind HB2
0104       lay = 18;
0105       for (ieta = 1; ieta < 16; ieta++) {
0106         for (iphi = 5; iphi < 8; iphi++) {
0107           id = HcalTestNumbering::packHcalIndex(0, 0, 1, ieta, iphi, lay);
0108           tmp.push_back(id);
0109         }
0110       }
0111     } else {
0112       // HB1 & HB2
0113       for (ieta = 1; ieta < 17; ieta++) {
0114         for (iphi = 1; iphi < 9; iphi++) {
0115           id = HcalTestNumbering::packHcalIndex(0, 0, 1, ieta, iphi, 1);
0116           tmp.push_back(id);
0117         }
0118       }
0119       // HO behind HB
0120       for (ieta = 1; ieta < 16; ieta++) {
0121         for (iphi = 2; iphi < 8; iphi++) {
0122           id = HcalTestNumbering::packHcalIndex(0, 0, 1, ieta, iphi, 2);
0123           tmp.push_back(id);
0124         }
0125       }
0126     }
0127   }
0128 
0129   if (type > 0) {
0130     // Include HE id's
0131     for (ieta = 15; ieta < 17; ieta++) {
0132       for (iphi = 3; iphi < 7; iphi++) {
0133         id = HcalTestNumbering::packHcalIndex(0, 0, 1, ieta, iphi, 3);
0134         tmp.push_back(id);
0135       }
0136     }
0137     for (iphi = 3; iphi < 7; iphi++) {
0138       id = HcalTestNumbering::packHcalIndex(0, 0, 1, 17, iphi, 1);
0139       tmp.push_back(id);
0140     }
0141     for (ieta = 18; ieta < 21; ieta++) {
0142       for (iphi = 3; iphi < 7; iphi++) {
0143         for (int idep = 1; idep < 3; idep++) {
0144           id = HcalTestNumbering::packHcalIndex(0, 0, 1, ieta, iphi, idep);
0145           tmp.push_back(id);
0146         }
0147       }
0148     }
0149     for (ieta = 21; ieta < 26; ieta++) {
0150       for (iphi = 2; iphi < 4; iphi++) {
0151         for (int idep = 1; idep < 3; idep++) {
0152           id = HcalTestNumbering::packHcalIndex(0, 0, 1, ieta, iphi, idep);
0153           tmp.push_back(id);
0154         }
0155       }
0156     }
0157   }
0158 
0159   return tmp;
0160 }