CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/SimCalorimetry/EcalSelectiveReadoutAlgos/src/EcalSelectiveReadout.h

Go to the documentation of this file.
00001 //emacs settings:-*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil -*-"
00002 /*
00003  * $Id: EcalSelectiveReadout.h,v 1.9 2009/10/26 10:41:26 pgras Exp $
00004  */
00005 
00006 #ifndef ECALSELECTIVEREADOUT_H
00007 #define ECALSELECTIVEREADOUT_H
00008 
00009 #include <vector>
00010 #include <iosfwd>
00011 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00012 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00013 #include "DataFormats/EcalDetId/interface/EcalScDetId.h"
00014 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
00015 #include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h"
00016 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
00017 
00018 #define ECALSELECTIVEREADOUT_NOGEOM //version w/o geometry dependency.
00019 
00020 #ifndef ECALSELECTIVEREADOUT_NOGEOM
00021 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00022 #endif //ECALSELECTIVEREADOUT_NOGEOM not defined
00023 
00024 
00025 
00065 class EcalSelectiveReadout {
00066 public:
00067   static const int FORCED_MASK = 0x4;
00068 
00069   //type definitions
00072   typedef enum {UNKNOWN             = -1 & ~FORCED_MASK,
00073                 LOWINTEREST         = 0x0,
00074                 SINGLE              = 0x1,
00075                 NEIGHBOUR           = 0x2,
00076                 CENTER              = 0x3,
00077                 FORCED_LOWINTEREST  = 0x4, //0x0 | 0x4
00078                 FORCED_SINGLE       = 0x5, //0x1 | 0x4
00079                 FORCED_NEIGHBOUR    = 0x6, //0x2 | 0x4
00080                 FORCED_CENTER       = 0x7  //0x3 | 0x4
00081   } towerInterest_t;
00082 
00083   typedef enum {
00084     TTF_UNKNOWN                     =-1,
00085     TTF_LOW_INTEREST                = 0x0,
00086     TTF_MID_INTEREST                = 0x1,
00087     /* 0x2 not used */
00088     TTF_HIGH_INTEREST               = 0X3,
00089     TTF_FORCED_LOW_INTEREST         = 0x4, //0x0 | 0x4
00090     TTF_FORCED_MID_INTEREST         = 0x5, //0x1 | 0x4
00091     /* 0x6 not used*/
00092     TTF_FORCED_HIGH_INTEREST        = 0x7  //0x3 | 0x4
00093 //     TTF_FORCED_RO_LINK_SYNC_ERR = 0x4,
00094 //     TTF_FORCED_RO_HAMMING_ERR = 0X5,
00095 //     TTF_FORCED_RO_OTHER1 = 0X6,
00096 //     TTF_FORCED_RO_OTHER2 = 0X7
00097   } ttFlag_t;
00098 
00099   //deprecated. Use instead FORCED_MASK
00100   static const int TTF_FORCED_RO_MASK = FORCED_MASK;
00101 
00102 
00103   //constants
00104 public:
00107   const static size_t nBarrelEtaBins = 170;
00110   const static size_t nBarrelPhiBins = 360;
00113   const static size_t nEndcapXBins = 100;
00116   const static size_t nEndcapYBins = 100;
00119   const static size_t supercrystalEdge = 5;
00122   const static size_t nSupercrystalXBins = nEndcapXBins/supercrystalEdge;
00125   const static size_t nSupercrystalYBins = nEndcapYBins/supercrystalEdge;
00128   const static size_t nBarrelTowerEtaBins = nBarrelEtaBins/5;
00131   const static size_t nBarrelTowerPhiBins = nBarrelPhiBins/5;
00134   const static size_t nEndcaps = 2;
00137   const static size_t nEndcapTriggerTowersInEta = 11;
00140   const static size_t nBarrelTriggerTowersInEta = 34;
00143   const static size_t nTriggerTowersInEta =
00144   2*nEndcapTriggerTowersInEta+nBarrelTriggerTowersInEta;
00147   const static size_t nTriggerTowersInPhi = 72;
00148 
00152   const static int maxDccChs = 68;
00153 
00156   const static int nDccPerEe = 9;
00157 
00158   //constructor(s) and destructor(s)
00159 public:
00168   EcalSelectiveReadout(int dEta = 1, int dPhi = 1);
00169 
00170   //method(s)
00171 
00173   void setTriggerMap(const EcalTrigTowerConstituentsMap * map) {
00174     theTriggerMap = map;
00175   }
00176 
00179   void setElecMap(const EcalElectronicsMapping * map) {
00180     theElecMap = map;
00181   }
00182 
00183 
00184 #ifndef ECALSELECTIVEREADOUT_NOGEOM
00185   void setGeometry(const CaloGeometry * caloGeometry) {
00186     theGeometry = caloGeometry;
00187   }
00188 #endif //ECALSELECTIVEREADOUT_NOGEOM not defined
00189 
00217   void runSelectiveReadout0(const ttFlag_t
00218                             towerFlags[nTriggerTowersInEta][nTriggerTowersInPhi]);
00219 
00224   towerInterest_t getCrystalInterest(const EBDetId & ebDetId) const;
00225 
00230   towerInterest_t getCrystalInterest(const EEDetId & eeDetId) const;
00231 
00236   towerInterest_t getSuperCrystalInterest(const EcalScDetId& scDetId) const;
00237 
00243   towerInterest_t getTowerInterest(const EcalTrigTowerDetId & towerId) const;
00244 
00246   void printHeader(std::ostream & os) const;
00247 
00249   void print(std::ostream & os) const;
00250 
00251   void printBarrel(std::ostream & os) const;
00252   void printEndcap(int endcap, std::ostream & s) const;
00253 
00254 private:
00255 
00261   towerInterest_t& eeRuInterest(const EEDetId& id);
00262 
00268   towerInterest_t& eeRuInterest(const EcalScDetId& id);
00269 
00276   void
00277   classifyTriggerTowers(const ttFlag_t ttFlags[nTriggerTowersInEta][nTriggerTowersInPhi]);
00278 
00281   void resetEeRuInterest();
00282 
00289   void setLower(int& var, int val) const{
00290     if(val<var) var = val;
00291   }
00292 
00299   template<class T>
00300   void setHigher(T& var, T val) const{
00301     if(val>var) var = val;
00302   }
00303 
00310   template<class T>
00311   void combineFlags(T& var, T val) const{
00312     var = (T)(std::max(val & ~TTF_FORCED_RO_MASK,  //actual flag value:
00313                        //                            take highest
00314                        var  & ~TTF_FORCED_RO_MASK) //beware: must work also
00315               //                                     for UNKNOW=-1
00316               //                                     ->compare the whole
00317               //                                     integer but with
00318               //                                     the forced bit masked.
00319               | ((val | var) & 0x4));//forced bit: set it if any of the two is
00320     //                                 already set
00321     
00322     
00323     if(var < 0 || var > 7){
00324       std::cout << __FILE__ << ":" << __LINE__ << ": ---------->"
00325            <<  var << " " << val << " "
00326            << std::max(val & 0x3, var  & 0x3) << " "
00327            << (val | var) << " "
00328            <<  ((val | var) & 0x4) << " "
00329            << (std::max(val & 0x3, var  & 0x3)
00330                | ((val | var) & 0x4)) <<  " "
00331            << (T)(std::max(val & 0x3, var  & 0x3)
00332                   | ((val | var) & 0x4)) << "\n";
00333         }
00334   }
00335 
00336 
00337 //   /** Propagate TTF flag bit on towerInterest. TT interest forced bit is set
00338 //    * if TTF forced bit is set, otherwise it is not touched.
00339 //    * @param ttFlags TT flags
00340 //    */
00341 //   void propagateTtForcedBit(const ttFlag_t ttFlags[nTriggerTowersInEta][nTriggerTowersInPhi]);
00342 
00343   void printDccChMap(std::ostream& os) const;
00344 
00345   //attribute(s)
00346 private:
00347 
00348   const EcalTrigTowerConstituentsMap * theTriggerMap;
00349   const EcalElectronicsMapping* theElecMap;
00350 
00351 #ifndef ECALSELECTIVEREADOUT_NOGEOM
00352   const CaloGeometry * theGeometry;
00353 #endif //ECALSELECTIVEREADOUT_NOGEOM not defined
00354   towerInterest_t towerInterest[nTriggerTowersInEta][nTriggerTowersInPhi];
00355   //towerInterest_t supercrystalInterest[nEndcaps][nSupercrystalXBins][nSupercrystalYBins];
00356   towerInterest_t eeRuInterest_[nEndcaps][nDccPerEe][maxDccChs];
00357   int dEta;
00358   int dPhi;
00359 
00360   // for printout
00361   const static char srpFlagMarker[];
00362 
00363 };
00364 
00365 std::ostream & operator<<(std::ostream & os, const EcalSelectiveReadout & selectiveReadout);
00366 
00367 #endif