CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EcalEBTrigPrimTestAlgo.h
Go to the documentation of this file.
1 #ifndef SimCalorimetry_EcalEBTrigPrimAlgos_EcalEBTrigPrimTestAlgo_h
2 #define SimCalorimetry_EcalEBTrigPrimAlgos_EcalEBTrigPrimTestAlgo_h
3 
9 #include <sys/time.h>
10 #include <iostream>
11 #include <vector>
12 
18 
22 
28 
29 #include <map>
30 #include <utility>
31 
32 class EcalTrigTowerDetId;
33 class ETPCoherenceTest;
35 class EBDataFrame;
36 
38 public:
39  // not BarrelOnly
41  const CaloGeometry *theGeometry,
42  int nSamples,
43  int binofmax,
44  bool tcpFormat,
45  bool debug,
46  bool famos);
47  //barrel only
48  explicit EcalEBTrigPrimTestAlgo(int nSamples, int binofmax, bool tcpFormat, bool debug, bool famos);
49 
50  virtual ~EcalEBTrigPrimTestAlgo();
51 
53 
54  void setPointers(const EcalTPGLinearizationConst *ecaltpLin,
55  const EcalTPGPedestals *ecaltpPed,
56  const EcalTPGCrystalStatus *ecaltpgBadX,
57  const EcalTPGWeightIdMap *ecaltpgWeightMap,
58  const EcalTPGWeightGroup *ecaltpgWeightGroup,
59  const EcalTPGSlidingWindow *ecaltpgSlidW,
60  const EcalTPGLutGroup *ecaltpgLutGroup,
61  const EcalTPGLutIdMap *ecaltpgLut,
62  const EcalTPGTowerStatus *ecaltpgBadTT,
63  const EcalTPGSpike *ecaltpgSpike) {
64  ecaltpPed_ = ecaltpPed;
65  ecaltpLin_ = ecaltpLin;
66  ecaltpgBadX_ = ecaltpgBadX;
67  ecaltpgWeightMap_ = ecaltpgWeightMap;
68  ecaltpgWeightGroup_ = ecaltpgWeightGroup;
69  ecaltpgSlidW_ = ecaltpgSlidW;
70  ecaltpgLutGroup_ = ecaltpgLutGroup;
71  ecaltpgLut_ = ecaltpgLut;
72  ecaltpgBadTT_ = ecaltpgBadTT;
73  ecaltpgSpike_ = ecaltpgSpike;
74  }
75 
76 private:
77  void init();
78  template <class T>
79  void initStructures(std::vector<std::vector<std::pair<int, std::vector<T> > > > &towMap);
80  template <class T>
81  void clean(std::vector<std::vector<std::pair<int, std::vector<T> > > > &towerMap);
82  template <class Coll>
83  void fillMap(Coll const *col,
84  std::vector<std::vector<std::pair<int, std::vector<typename Coll::Digi> > > > &towerMap);
85  int findStripNr(const EBDetId &id);
86  int findStripNr(const EEDetId &id);
87 
88  // FIXME: temporary until hashedIndex works alsom for endcap
89  int getIndex(const EBDigiCollection *, EcalTrigTowerDetId &id) { return id.hashedIndex(); }
90  // mind that eta is continuous between barrel+endcap
92  int ind = (id.ietaAbs() - 18) * 72 + id.iphi();
93  if (id.zside() < 0)
94  ind += 792;
95  return ind;
96  }
97 
99  const CaloGeometry *theGeometry_ = nullptr;
100 
101  float threshold;
105 
108  bool debug_;
109  bool famos_;
110 
111  int nrTowers_; // nr of towers found by fillmap method
112  static const unsigned int maxNrTowers_;
113  static const unsigned int maxNrSamplesOut_;
114  static const unsigned int nrSamples_;
115 
116  // data structures kept during the whole run
117  std::vector<std::vector<int> > striptp_;
118  std::vector<std::vector<std::pair<int, std::vector<EBDataFrame> > > > towerMapEB_;
119  std::vector<std::vector<std::pair<int, std::vector<EEDataFrame> > > > towerMapEE_;
120  std::vector<std::pair<int, EcalTrigTowerDetId> > hitTowers_;
121  std::vector<EcalEBTriggerPrimitiveSample> towtp_;
122  std::vector<EcalEBTriggerPrimitiveSample> towtp2_;
123 
124  enum { nbMaxStrips_ = 5 };
125  enum { nbMaxXtals_ = 5 };
126 
128 
129  std::vector<EcalEBFenixLinearizer *> linearizer_;
134 
135  //
146 
148  std::vector<std::vector<int> > lin_out_;
149  //
151  std::vector<int> filt_out_;
152  std::vector<int> peak_out_;
153  std::vector<int> format_out_;
154  // these two are dummy
155  std::vector<int> fgvb_out_;
156  std::vector<int> fgvb_out_temp_;
157 
158  //
161  //
163  std::vector<int> tcpformat_out_;
164 };
165 
166 template <class T>
167 void EcalEBTrigPrimTestAlgo::clean(std::vector<std::vector<std::pair<int, std::vector<T> > > > &towMap) {
168  // clean internal data structures
169  for (unsigned int i = 0; i < maxNrTowers_; ++i)
170  for (int j = 0; j < nbMaxStrips_; ++j)
171  (towMap[i])[j].first = 0;
172  return;
173 }
174 
175 template <class Coll>
177  Coll const *col, std::vector<std::vector<std::pair<int, std::vector<typename Coll::Digi> > > > &towerMap) {
178  typedef typename Coll::Digi Digi;
179 
180  // implementation for Barrel
181  if (col) {
182  nrTowers_ = 0;
183  if (debug_)
184  std::cout << "Fill mapping, Collection size = " << col->size() << std::endl;
185  ;
186  for (unsigned int i = 0; i < col->size(); ++i) {
187  Digi samples((*col)[i]);
188  EcalTrigTowerDetId coarser = (*eTTmap_).towerOf(samples.id());
189  int index = getIndex(col, coarser);
190  int stripnr = findStripNr(samples.id());
191 
192  int filled = 0;
193  for (unsigned int ij = 0; ij < towerMap[index].size(); ++ij)
194  filled += towerMap[index][ij].first;
195  if (!filled) {
196  hitTowers_[nrTowers_++] = std::pair<int, EcalTrigTowerDetId>(index, coarser);
197  }
198 
199  //FIXME: temporary protection
200  int ncryst = towerMap[index][stripnr - 1].first;
201  if (ncryst >= nbMaxXtals_) {
202  edm::LogError("EcalTrigPrimFunctionAlgo")
203  << "! Too many xtals for TT " << coarser << " stripnr " << stripnr << " xtalid " << samples.id();
204  continue;
205  }
206  ((towerMap[index])[stripnr - 1].second)[ncryst] = samples;
207  (towerMap[index])[stripnr - 1].first++;
208  }
209 
210  if (debug_)
211  std::cout << "fillMap"
212  << "[EcalTrigPrimFunctionalAlgo] (found " << col->size() << " frames in " << towerMap.size()
213  << " towers) " << std::endl;
214  } else {
215  if (debug_)
216  std::cout << "FillMap - FillMap Collection size=0 !!!!" << std::endl;
217  ;
218  }
219 }
220 
221 template <class T>
222 void EcalEBTrigPrimTestAlgo::initStructures(std::vector<std::vector<std::pair<int, std::vector<T> > > > &towMap) {
223  //initialise internal data structures
224 
225  std::vector<T> vec0(nbMaxXtals_);
226  std::vector<std::pair<int, std::vector<T> > > vec1(nbMaxStrips_);
227  for (int i = 0; i < nbMaxStrips_; ++i)
228  vec1[i] = std::pair<int, std::vector<T> >(0, vec0);
229  towMap.resize(maxNrTowers_);
230  for (unsigned int i = 0; i < maxNrTowers_; ++i)
231  towMap[i] = vec1;
232 
233  std::vector<int> vecint(maxNrSamples_);
234  striptp_.resize(nbMaxStrips_);
235  for (int i = 0; i < nbMaxStrips_; ++i)
236  striptp_[i] = vecint;
237 }
238 
239 #endif
std::vector< std::vector< std::pair< int, std::vector< EEDataFrame > > > > towerMapEE_
calculates .... for Fenix strip, barrel input: 18 bits output: 18 bits
std::vector< EcalEBTriggerPrimitiveSample > towtp2_
const CaloGeometry * theGeometry_
static const unsigned int nrSamples_
void fillMap(Coll const *col, std::vector< std::vector< std::pair< int, std::vector< typename Coll::Digi > > > > &towerMap)
std::vector< int > format_out_
static const unsigned int maxNrSamplesOut_
Linearisation for Fenix strip input: 16 bits corresponding to input EBDataFrame output: 18 bits...
Formatting for Fenix strip input: 18 bits + 3x 1bit (fgvb, gapflagbit, output from peakfinder) output...
EcalEBFenixStripFormatEB * getFormatterEB() const
const EcalTPGSlidingWindow * ecaltpgSlidW_
int zside(DetId const &)
Log< level::Error, false > LogError
std::vector< std::vector< int > > striptp_
const EcalTPGSpike * ecaltpgSpike_
const EcalTPGCrystalStatus * ecaltpgBadX_
tuple result
Definition: mps_fire.py:311
EcalEBFenixAmplitudeFilter * amplitude_filter_
EcalEBFenixPeakFinder * peak_finder_
U second(std::pair< T, U > const &p)
const EcalTPGLinearizationConst * ecaltpLin_
std::vector< std::pair< int, EcalTrigTowerDetId > > hitTowers_
Formatting for Fenix Tcp input 10 bits from Ettot 1 bit from fgvb 3 bits TriggerTowerFlag output: 16 ...
std::vector< double > vec1
Definition: HCALResponse.h:15
const EcalTrigTowerConstituentsMap * eTTmap_
constexpr size_t nSamples
std::vector< std::vector< std::pair< int, std::vector< EBDataFrame > > > > towerMapEB_
void initStructures(std::vector< std::vector< std::pair< int, std::vector< T > > > > &towMap)
const EcalTPGWeightGroup * ecaltpgWeightGroup_
const EcalTPGTowerStatus * ecaltpgBadTT_
EcalEBFenixStripFormatEB * fenixFormatterEB_
calculates the peak for Fenix strip, barrel input : 18 bits output: boolean
#define debug
Definition: HDRShower.cc:19
int getIndex(const EEDigiCollection *, EcalTrigTowerDetId &id)
int getIndex(const EBDigiCollection *, EcalTrigTowerDetId &id)
static const unsigned int maxNrTowers_
EcalEBFenixTcpFormat * getFormatter() const
std::vector< int > fgvb_out_temp_
void setPointers(const EcalTPGLinearizationConst *ecaltpLin, const EcalTPGPedestals *ecaltpPed, const EcalTPGCrystalStatus *ecaltpgBadX, const EcalTPGWeightIdMap *ecaltpgWeightMap, const EcalTPGWeightGroup *ecaltpgWeightGroup, const EcalTPGSlidingWindow *ecaltpgSlidW, const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGTowerStatus *ecaltpgBadTT, const EcalTPGSpike *ecaltpgSpike)
EcalEBFenixPeakFinder * getPeakFinder() const
std::vector< int > tcpformat_out_
int findStripNr(const EBDetId &id)
const EcalElectronicsMapping * theMapping_
void run(const EBDigiCollection *col, EcalEBTrigPrimDigiCollection &result, EcalEBTrigPrimDigiCollection &resultTcp)
tuple cout
Definition: gather_cfg.py:144
EcalEBFenixAmplitudeFilter * getFilter() const
EcalEBFenixTcpFormat * fenixTcpFormat_
int col
Definition: cuy.py:1009
void clean(std::vector< std::vector< std::pair< int, std::vector< T > > > > &towerMap)
std::vector< EcalEBFenixLinearizer * > linearizer_
EcalEBTrigPrimTestAlgo(const EcalTrigTowerConstituentsMap *eTTmap, const CaloGeometry *theGeometry, int nSamples, int binofmax, bool tcpFormat, bool debug, bool famos)
const EcalTPGPedestals * ecaltpPed_
const EcalTPGLutIdMap * ecaltpgLut_
const EcalTPGLutGroup * ecaltpgLutGroup_
EcalEBFenixLinearizer * getLinearizer(int i) const
std::vector< std::vector< int > > lin_out_
std::vector< EcalEBTriggerPrimitiveSample > towtp_
const EcalTPGWeightIdMap * ecaltpgWeightMap_