00001
00002
00003
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
00017 #define ECALSELECTIVEREADOUT_NOGEOM //version w/o geometry dependency.
00018
00019 #ifndef ECALSELECTIVEREADOUT_NOGEOM
00020 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00021 #endif //ECALSELECTIVEREADOUT_NOGEOM not defined
00022
00023
00024
00047 class EcalSelectiveReadout {
00048 public:
00049
00052 typedef enum {UNKNOWN=-1,
00053 LOWINTEREST,
00054 SINGLE,
00055 NEIGHBOUR,
00056 CENTER,
00057 FORCED_RO} towerInterest_t;
00058
00059 typedef enum {
00060 TTF_UNKNOWN=-1,
00061 TTF_LOW_INTEREST = 0x0,
00062 TTF_MID_INTEREST = 0x1,
00063
00064 TTF_HIGH_INTEREST = 0X3,
00065 TTF_FORCED_RO_LINK_SYNC_ERR = 0x4,
00066 TTF_FORCED_RO_HAMMING_ERR = 0X5,
00067 TTF_FORCED_RO_OTHER1 = 0X6,
00068 TTF_FORCED_RO_OTHER2 = 0X7
00069 } ttFlag_t;
00070
00071 static const int TTF_FORCED_RO_MASK = 0x4;
00072
00073
00074 public:
00077 const static size_t nBarrelEtaBins = 170;
00080 const static size_t nBarrelPhiBins = 360;
00083 const static size_t nEndcapXBins = 100;
00086 const static size_t nEndcapYBins = 100;
00089 const static size_t supercrystalEdge = 5;
00092 const static size_t nSupercrystalXBins = nEndcapXBins/supercrystalEdge;
00095 const static size_t nSupercrystalYBins = nEndcapYBins/supercrystalEdge;
00098 const static size_t nBarrelTowerEtaBins = nBarrelEtaBins/5;
00101 const static size_t nBarrelTowerPhiBins = nBarrelPhiBins/5;
00104 const static size_t nEndcaps = 2;
00107 const static size_t nEndcapTriggerTowersInEta = 11;
00110 const static size_t nBarrelTriggerTowersInEta = 34;
00113 const static size_t nTriggerTowersInEta =
00114 2*nEndcapTriggerTowersInEta+nBarrelTriggerTowersInEta;
00117 const static size_t nTriggerTowersInPhi = 72;
00118
00119
00120 public:
00129 EcalSelectiveReadout(int dEta = 1, int dPhi = 1);
00130
00131
00132
00134 void setTriggerMap(const EcalTrigTowerConstituentsMap * map) {
00135 theTriggerMap = map;
00136 }
00137
00138 #ifndef ECALSELECTIVEREADOUT_NOGEOM
00139 void setGeometry(const CaloGeometry * caloGeometry) {
00140 theGeometry = caloGeometry;
00141 }
00142 #endif //ECALSELECTIVEREADOUT_NOGEOM not defined
00143
00171 void runSelectiveReadout0(const ttFlag_t
00172 towerFlags[nTriggerTowersInEta][nTriggerTowersInPhi]);
00173
00178 towerInterest_t getCrystalInterest(const EBDetId & ebDetId) const;
00179
00184 towerInterest_t getCrystalInterest(const EEDetId & eeDetId) const;
00185
00190 towerInterest_t getSuperCrystalInterest(const EcalScDetId& scDetId) const;
00191
00197 towerInterest_t getTowerInterest(const EcalTrigTowerDetId & towerId) const;
00198
00200 void printHeader(std::ostream & os) const;
00201
00203 void print(std::ostream & os) const;
00204
00205 void printBarrel(std::ostream & os) const;
00206 void printEndcap(int endcap, std::ostream & s) const;
00207
00208 private:
00209
00216 void
00217 classifyTriggerTowers(const ttFlag_t ttFlags[nTriggerTowersInEta][nTriggerTowersInPhi]);
00218
00219
00222 void resetSupercrystalInterest();
00223
00230 void setLower(int& var, int val) const{
00231 if(val<var) var = val;
00232 }
00233
00240 template<class T>
00241 void setHigher(T& var, T val) const{
00242 if(val>var) var = val;
00243 }
00244
00245
00246 private:
00247
00248 const EcalTrigTowerConstituentsMap * theTriggerMap;
00249 #ifndef ECALSELECTIVEREADOUT_NOGEOM
00250 const CaloGeometry * theGeometry;
00251 #endif //ECALSELECTIVEREADOUT_NOGEOM not defined
00252 towerInterest_t towerInterest[nTriggerTowersInEta][nTriggerTowersInPhi];
00253 towerInterest_t supercrystalInterest[nEndcaps][nSupercrystalXBins][nSupercrystalYBins];
00254 int dEta;
00255 int dPhi;
00256
00257
00258 const static char srpFlagMarker[];
00259
00260 };
00261
00262 std::ostream & operator<<(std::ostream & os, const EcalSelectiveReadout & selectiveReadout);
00263
00264 #endif