Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:35

0001 /** \class HcalGenericDetId
0002     \author F.Ratnikov, UMd
0003    Generic HCAL detector ID suitable for all Hcal subdetectors
0004 */
0005 
0006 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
0007 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0008 #include "DataFormats/HcalDetId/interface/HcalTrigTowerDetId.h"
0009 #include "DataFormats/HcalDetId/interface/HcalZDCDetId.h"
0010 #include "DataFormats/HcalDetId/interface/HcalCastorDetId.h"
0011 #include "DataFormats/HcalDetId/interface/HcalCalibDetId.h"
0012 #include <iostream>
0013 #include <cstdlib>
0014 
0015 HcalOtherSubdetector HcalGenericDetId::otherSubdet() const {
0016   if (HcalSubdetector(subdetId()) != HcalOther)
0017     return HcalOtherEmpty;
0018   return HcalOtherSubdetector((rawId() >> 20) & 0x1F);
0019 }
0020 
0021 HcalGenericDetId::HcalGenericSubdetector HcalGenericDetId::genericSubdet() const {
0022   if (null())
0023     return HcalGenEmpty;
0024   switch (det()) {
0025     case Calo:
0026       switch (subdetId()) {
0027         case HcalZDCDetId::SubdetectorId:
0028           return HcalGenZDC;
0029         case HcalCastorDetId::SubdetectorId:
0030           return HcalGenCastor;
0031         default:
0032           return HcalGenUnknown;
0033       }
0034     case Hcal:
0035       switch (HcalSubdetector(subdetId())) {
0036         case 0:
0037           return HcalGenEmpty;
0038         case HcalBarrel:
0039           return HcalGenBarrel;
0040         case HcalEndcap:
0041           return HcalGenEndcap;
0042         case HcalOuter:
0043           return HcalGenOuter;
0044         case HcalForward:
0045           return HcalGenForward;
0046         case HcalTriggerTower:
0047           return HcalGenTriggerTower;
0048         case HcalOther:
0049           switch (otherSubdet()) {
0050             case HcalCalibration:
0051               return HcalGenCalibration;
0052             default:
0053               return HcalGenUnknown;
0054           }
0055         default:
0056           return HcalGenUnknown;
0057       }
0058     default:
0059       return HcalGenUnknown;
0060   }
0061   return HcalGenUnknown;
0062 }
0063 
0064 bool HcalGenericDetId::isHcalDetId() const {
0065   HcalGenericSubdetector subdet = genericSubdet();
0066   return subdet == HcalGenBarrel || subdet == HcalGenEndcap || subdet == HcalGenOuter || subdet == HcalGenForward;
0067 }
0068 
0069 bool HcalGenericDetId::isHcalCalibDetId() const {
0070   HcalGenericSubdetector subdet = genericSubdet();
0071   return subdet == HcalGenCalibration;
0072 }
0073 
0074 bool HcalGenericDetId::isHcalTrigTowerDetId() const {
0075   HcalGenericSubdetector subdet = genericSubdet();
0076   return subdet == HcalGenTriggerTower;
0077 }
0078 
0079 bool HcalGenericDetId::isHcalZDCDetId() const {
0080   HcalGenericSubdetector subdet = genericSubdet();
0081   return subdet == HcalGenZDC;
0082 }
0083 
0084 bool HcalGenericDetId::isHcalCastorDetId() const {
0085   HcalGenericSubdetector subdet = genericSubdet();
0086   return subdet == HcalGenCastor;
0087 }
0088 
0089 std::ostream& operator<<(std::ostream& s, const HcalGenericDetId& id) {
0090   if (id.null())
0091     s << "(Null Id)";
0092   else
0093     switch (id.genericSubdet()) {
0094       case HcalGenericDetId::HcalGenBarrel:
0095       case HcalGenericDetId::HcalGenEndcap:
0096       case HcalGenericDetId::HcalGenOuter:
0097       case HcalGenericDetId::HcalGenForward:
0098         s << HcalDetId(id);
0099         break;
0100       case HcalGenericDetId::HcalGenTriggerTower:
0101         s << HcalTrigTowerDetId(id);
0102         break;
0103       case HcalGenericDetId::HcalGenZDC:
0104         s << HcalZDCDetId(id);
0105         break;
0106       case HcalGenericDetId::HcalGenCastor:
0107         s << HcalCastorDetId(id);
0108         break;
0109       case HcalGenericDetId::HcalGenCalibration:
0110         s << HcalCalibDetId(id);
0111         break;
0112       default:
0113         s << "(Hcal Unknown Id: 0x" << std::hex << id.rawId() << std::dec << ')';
0114     }
0115   return s;
0116 }