CMS 3D CMS Logo

EcalSelectiveReadout.h
Go to the documentation of this file.
1 //emacs settings:-*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil -*-"
2 /*
3  */
4 
5 #ifndef ECALSELECTIVEREADOUT_H
6 #define ECALSELECTIVEREADOUT_H
7 
8 #include <vector>
9 #include <iosfwd>
16 
17 #define ECALSELECTIVEREADOUT_NOGEOM //version w/o geometry dependency.
18 
19 #ifndef ECALSELECTIVEREADOUT_NOGEOM
21 #endif //ECALSELECTIVEREADOUT_NOGEOM not defined
22 
63 public:
64  static const int FORCED_MASK = 0x4;
65 
66  //type definitions
69  typedef enum {
71  LOWINTEREST = 0x0,
72  SINGLE = 0x1,
73  NEIGHBOUR = 0x2,
74  CENTER = 0x3,
75  FORCED_LOWINTEREST = 0x4, //0x0 | 0x4
76  FORCED_SINGLE = 0x5, //0x1 | 0x4
77  FORCED_NEIGHBOUR = 0x6, //0x2 | 0x4
78  FORCED_CENTER = 0x7 //0x3 | 0x4
80 
81  typedef enum {
85  /* 0x2 not used */
87  TTF_FORCED_LOW_INTEREST = 0x4, //0x0 | 0x4
88  TTF_FORCED_MID_INTEREST = 0x5, //0x1 | 0x4
89  /* 0x6 not used*/
90  TTF_FORCED_HIGH_INTEREST = 0x7 //0x3 | 0x4
91  // TTF_FORCED_RO_LINK_SYNC_ERR = 0x4,
92  // TTF_FORCED_RO_HAMMING_ERR = 0X5,
93  // TTF_FORCED_RO_OTHER1 = 0X6,
94  // TTF_FORCED_RO_OTHER2 = 0X7
95  } ttFlag_t;
96 
97  //deprecated. Use instead FORCED_MASK
98  static const int TTF_FORCED_RO_MASK = FORCED_MASK;
99 
100  //constants
101 public:
104  const static size_t nBarrelEtaBins = 170;
107  const static size_t nBarrelPhiBins = 360;
110  const static size_t nEndcapXBins = 100;
113  const static size_t nEndcapYBins = 100;
116  const static size_t supercrystalEdge = 5;
125  const static size_t nBarrelTowerEtaBins = nBarrelEtaBins / 5;
128  const static size_t nBarrelTowerPhiBins = nBarrelPhiBins / 5;
131  const static size_t nEndcaps = 2;
134  const static size_t nEndcapTriggerTowersInEta = 11;
137  const static size_t nBarrelTriggerTowersInEta = 34;
143  const static size_t nTriggerTowersInPhi = 72;
144 
148  const static int maxDccChs = 68;
149 
152  const static int nDccPerEe = 9;
153 
154  //constructor(s) and destructor(s)
155 public:
164  EcalSelectiveReadout(int dEta = 1, int dPhi = 1);
165 
166  //method(s)
167 
170 
174 
175 #ifndef ECALSELECTIVEREADOUT_NOGEOM
176  void setGeometry(const CaloGeometry* caloGeometry) { theGeometry = caloGeometry; }
177 #endif //ECALSELECTIVEREADOUT_NOGEOM not defined
178 
207 
212  towerInterest_t getCrystalInterest(const EBDetId& ebDetId) const;
213 
218  towerInterest_t getCrystalInterest(const EEDetId& eeDetId) const;
219 
225 
232 
234  void printHeader(std::ostream& os) const;
235 
237  void print(std::ostream& os) const;
238 
239  void printBarrel(std::ostream& os) const;
240  void printEndcap(int endcap, std::ostream& s) const;
241 
242 private:
249 
256 
264 
267  void resetEeRuInterest();
268 
275  void setLower(int& var, int val) const {
276  if (val < var)
277  var = val;
278  }
279 
286  template <class T>
287  void setHigher(T& var, T val) const {
288  if (val > var)
289  var = val;
290  }
291 
298  template <class T>
299  void combineFlags(T& var, T val) const {
300  var = (T)(std::max(val & ~TTF_FORCED_RO_MASK, //actual flag value:
301  // take highest
302  var & ~TTF_FORCED_RO_MASK) //beware: must work also
303  // for UNKNOW=-1
304  // ->compare the whole
305  // integer but with
306  // the forced bit masked.
307  | ((val | var) & 0x4)); //forced bit: set it if any of the two is
308  // already set
309 
310  if (var < 0 || var > 7) {
311  std::cout << __FILE__ << ":" << __LINE__ << ": ---------->" << var << " " << val << " "
312  << std::max(val & 0x3, var & 0x3) << " " << (val | var) << " " << ((val | var) & 0x4) << " "
313  << (std::max(val & 0x3, var & 0x3) | ((val | var) & 0x4)) << " "
314  << (T)(std::max(val & 0x3, var & 0x3) | ((val | var) & 0x4)) << "\n";
315  }
316  }
317 
318  // /** Propagate TTF flag bit on towerInterest. TT interest forced bit is set
319  // * if TTF forced bit is set, otherwise it is not touched.
320  // * @param ttFlags TT flags
321  // */
322  // void propagateTtForcedBit(const ttFlag_t ttFlags[nTriggerTowersInEta][nTriggerTowersInPhi]);
323 
324  void printDccChMap(std::ostream& os) const;
325 
326  //attribute(s)
327 private:
330 
331 #ifndef ECALSELECTIVEREADOUT_NOGEOM
332  const CaloGeometry* theGeometry;
333 #endif //ECALSELECTIVEREADOUT_NOGEOM not defined
335  //towerInterest_t supercrystalInterest[nEndcaps][nSupercrystalXBins][nSupercrystalYBins];
337  int dEta;
338  int dPhi;
339 
340  // for printout
341  const static char srpFlagMarker[];
342 };
343 
344 std::ostream& operator<<(std::ostream& os, const EcalSelectiveReadout& selectiveReadout);
345 
346 #endif
void printEndcap(int endcap, std::ostream &s) const
void printHeader(std::ostream &os) const
print out header for the map: see print(std::ostream&)
static const int FORCED_MASK
static const size_t nEndcapXBins
void setTriggerMap(const EcalTrigTowerConstituentsMap *map)
the mapping of which cell goes with which trigger tower
towerInterest_t getCrystalInterest(const EBDetId &ebDetId) const
void setLower(int &var, int val) const
static const size_t nSupercrystalXBins
static const int TTF_FORCED_RO_MASK
static const size_t nEndcaps
static const int nDccPerEe
static const size_t nBarrelPhiBins
void classifyTriggerTowers(const ttFlag_t ttFlags[nTriggerTowersInEta][nTriggerTowersInPhi])
towerInterest_t & eeRuInterest(const EEDetId &id)
static const size_t nEndcapYBins
static const size_t nSupercrystalYBins
void printBarrel(std::ostream &os) const
static const size_t nBarrelTowerPhiBins
EcalSelectiveReadout(int dEta=1, int dPhi=1)
unsigned towerId(DetId const &, EcalElectronicsMapping const *)
static const size_t supercrystalEdge
static const int maxDccChs
static const size_t nEndcapTriggerTowersInEta
const EcalElectronicsMapping * theElecMap
towerInterest_t eeRuInterest_[nEndcaps][nDccPerEe][maxDccChs]
const EcalTrigTowerConstituentsMap * theTriggerMap
towerInterest_t getTowerInterest(const EcalTrigTowerDetId &towerId) const
void combineFlags(T &var, T val) const
static const size_t nTriggerTowersInEta
static const size_t nTriggerTowersInPhi
void print(std::ostream &os) const
print out the map
static const char srpFlagMarker[]
void runSelectiveReadout0(const ttFlag_t towerFlags[nTriggerTowersInEta][nTriggerTowersInPhi])
towerInterest_t towerInterest[nTriggerTowersInEta][nTriggerTowersInPhi]
static const size_t nBarrelTriggerTowersInEta
void setHigher(T &var, T val) const
static const size_t nBarrelEtaBins
towerInterest_t getSuperCrystalInterest(const EcalScDetId &scDetId) const
static const size_t nBarrelTowerEtaBins
long double T
std::ostream & operator<<(std::ostream &os, const EcalSelectiveReadout &selectiveReadout)
void setElecMap(const EcalElectronicsMapping *map)
void printDccChMap(std::ostream &os) const