CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/RecoMET/METAlgorithms/interface/HcalHPDRBXMap.h

Go to the documentation of this file.
00001 #ifndef _RECOMET_METALGORITHMS_HCALHPDRBXMAP_H_
00002 #define _RECOMET_METALGORITHMS_HCALHPDRBXMAP_H_
00003 
00004 
00005 //
00006 // HcalHPDRBXMap.h
00007 //
00008 //   description: Algorithm which isomorphically maps HPD/RBX locations to
00009 //                integers ranging from 0 to NUM_HPDS-1/NUM_RBXS-1.  The HPDs/RBXs
00010 //                are ordered from lowest to highest: HB+, HB-, HE+, HE-.
00011 //                This is used extensively by the various HcalNoise container
00012 //                classes.  The constructor and destructor are hidden, since
00013 //                the only methods of interest are static.  All the methods
00014 //                here are O(1).
00015 //
00016 //   author: J.P. Chou, Brown
00017 //
00018 
00019 #include "boost/array.hpp"
00020 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00021 #include "Geometry/CaloTopology/interface/HcalTopology.h"
00022 #include <vector>
00023 
00024 class HcalHPDRBXMap {
00025  public:
00026   
00027   // "magic numbers"
00028   // total number of HPDs in the HB and HE
00029   const static int NUM_HPDS=288;
00030   // total number of HPDs per subdetector (HB+, HB-, HE+, HE-)
00031   const static int NUM_HPDS_PER_SUBDET=72;
00032   // number of HPDs per RBX
00033   const static int NUM_HPDS_PER_RBX = 4;
00034   // total number of RBXs in the HB and HE
00035   const static int NUM_RBXS=72;
00036   // total number of RBXs per subdetector (e.g. HB+, HB-, HE+, HE-)
00037   const static int NUM_RBXS_PER_SUBDET=18;
00038 
00039   // access magic numbers by inline function
00040   inline int static numHPDs(void) { return NUM_HPDS; }
00041   inline int static numHPDsPerSubdet(void) { return NUM_HPDS_PER_SUBDET; }
00042   inline int static numHPDsPerRBX(void) { return NUM_HPDS_PER_RBX; }
00043   inline int static numRBXs(void) { return NUM_RBXS; }
00044   inline int static numRBXsPerSubdet(void) { return NUM_RBXS_PER_SUBDET; }
00045 
00046   // determines whether an HPD or RBX index is valid
00047   // HPDs run from [0,NUM_HPDS-1], and RBXs run from [0,NUM_RBXS-1]
00048   bool static isValidHPD(int index);
00049   bool static isValidRBX(int index);
00050   
00051   // determines whether a HcalDetId corresponds to a valid HPD/RBX
00052   // this requires that the HcalDetId be in the HB or HE
00053   bool static isValid(const HcalDetId&);
00054 
00055   // determines whether the ieta, iphi coordinate corresponds to a valid HPD/RBX
00056   bool static isValid(int ieta, int iphi);
00057 
00058   // location of the HPD/RBX in the detector based on the HPD/RBX index
00059   // exception is thrown if index is invalid
00060   HcalSubdetector static subdetHPD(int index);
00061   HcalSubdetector static subdetRBX(int index);
00062   int static zsideHPD(int index);
00063   int static zsideRBX(int index);
00064   int static iphiloHPD(int index);
00065   int static iphiloRBX(int index);
00066   int static iphihiHPD(int index);
00067   int static iphihiRBX(int index);
00068 
00069   // returns a list of HPD indices found in a given RBX
00070   // exception is thrown if rbxindex is invalid
00071   // HPD indices are ordered in phi-space
00072   void static indicesHPDfromRBX(int rbxindex, boost::array<int, NUM_HPDS_PER_RBX>& hpdindices);
00073 
00074   // returns the RBX index given an HPD index
00075   // exception is thrown if hpdindex is invalid
00076   int static indexRBXfromHPD(int hpdindex);
00077 
00078   // get the HPD/RBX index from an HcalDetector id
00079   // throws an exception if the HcalDetID does not correspond to a valid HPD/RBX
00080   int static indexHPD(const HcalDetId&);
00081   int static indexRBX(const HcalDetId&);
00082 
00083   // get the HPD/RBX indices corresponding to an ieta, iphi coordinate
00084   // throws an exception if the ieta and iphi do not correspond to a valid HPD/RBX
00085   void static indexHPDfromEtaPhi(int ieta, int iphi, std::vector<int>& hpdindices);
00086   void static indexRBXfromEtaPhi(int ieta, int iphi, std::vector<int>& rbxindices);
00087 
00088  private:
00089   HcalHPDRBXMap();
00090   ~HcalHPDRBXMap();
00091 
00092   // used to determine if a detector ID element is valid
00093   static HcalTopology theTopology_;
00094 
00095 };
00096 
00097 #endif