CMS 3D CMS Logo

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
EcalEBTrigPrimTestAlgo::nSamples_
int nSamples_
Definition: EcalEBTrigPrimTestAlgo.h:102
EcalEBTrigPrimTestAlgo::amplitude_filter_
EcalEBFenixAmplitudeFilter * amplitude_filter_
Definition: EcalEBTrigPrimTestAlgo.h:130
EcalEBTrigPrimTestAlgo::nrTowers_
int nrTowers_
Definition: EcalEBTrigPrimTestAlgo.h:111
EcalEBTrigPrimTestAlgo::binOfMaximum_
int binOfMaximum_
Definition: EcalEBTrigPrimTestAlgo.h:103
EcalEBFenixStripFormatEB
Formatting for Fenix strip input: 18 bits + 3x 1bit (fgvb, gapflagbit, output from peakfinder) output...
Definition: EcalEBFenixStripFormatEB.h:18
EcalElectronicsMapping
Definition: EcalElectronicsMapping.h:28
EcalTPGWeightIdMap
Definition: EcalTPGWeightIdMap.h:10
mps_fire.i
i
Definition: mps_fire.py:428
EcalEBTrigPrimTestAlgo::init
void init()
Definition: EcalEBTrigPrimTestAlgo.cc:79
EcalEBFenixPeakFinder.h
MessageLogger.h
EcalEBTrigPrimTestAlgo::maxNrTowers_
static const unsigned int maxNrTowers_
Definition: EcalEBTrigPrimTestAlgo.h:112
EcalEBTrigPrimTestAlgo::tcpFormat_
bool tcpFormat_
Definition: EcalEBTrigPrimTestAlgo.h:106
EcalEBTrigPrimTestAlgo::nbMaxXtals_
Definition: EcalEBTrigPrimTestAlgo.h:125
EcalEBTrigPrimTestAlgo::ecaltpgBadTT_
const EcalTPGTowerStatus * ecaltpgBadTT_
Definition: EcalEBTrigPrimTestAlgo.h:144
vec1
std::vector< double > vec1
Definition: HCALResponse.h:15
EcalEBTrigPrimTestAlgo::eTTmap_
const EcalTrigTowerConstituentsMap * eTTmap_
Definition: EcalEBTrigPrimTestAlgo.h:98
EcalEBFenixLinearizer
Linearisation for Fenix strip input: 16 bits corresponding to input EBDataFrame output: 18 bits.
Definition: EcalEBFenixLinearizer.h:19
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
EcalTPGSpike
Definition: EcalTPGSpike.h:9
EcalEBTrigPrimTestAlgo::setPointers
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)
Definition: EcalEBTrigPrimTestAlgo.h:54
EBDetId
Definition: EBDetId.h:17
EBDataFrame
Definition: EBDataFrame.h:11
cuy.col
col
Definition: cuy.py:1010
gather_cfg.cout
cout
Definition: gather_cfg.py:144
TrendClient_cfi.Digi
Digi
Definition: TrendClient_cfi.py:7
EcalEBTrigPrimTestAlgo::threshold
float threshold
Definition: EcalEBTrigPrimTestAlgo.h:101
edm::SortedCollection
Definition: SortedCollection.h:49
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
EcalEBTrigPrimTestAlgo::fgvb_out_temp_
std::vector< int > fgvb_out_temp_
Definition: EcalEBTrigPrimTestAlgo.h:156
EcalEBTrigPrimTestAlgo::findStripNr
int findStripNr(const EBDetId &id)
Definition: EcalEBTrigPrimTestAlgo.cc:319
EcalEBTrigPrimTestAlgo::getIndex
int getIndex(const EEDigiCollection *, EcalTrigTowerDetId &id)
Definition: EcalEBTrigPrimTestAlgo.h:91
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
EcalEBTrigPrimTestAlgo::initStructures
void initStructures(std::vector< std::vector< std::pair< int, std::vector< T > > > > &towMap)
Definition: EcalEBTrigPrimTestAlgo.h:222
EcalTPGWeightGroup
Definition: EcalTPGWeightGroup.h:8
EcalEBTrigPrimTestAlgo::getIndex
int getIndex(const EBDigiCollection *, EcalTrigTowerDetId &id)
Definition: EcalEBTrigPrimTestAlgo.h:89
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
EcalEBTrigPrimTestAlgo::theMapping_
const EcalElectronicsMapping * theMapping_
Definition: EcalEBTrigPrimTestAlgo.h:127
EcalEBTrigPrimTestAlgo::filt_out_
std::vector< int > filt_out_
Definition: EcalEBTrigPrimTestAlgo.h:151
EcalEBTrigPrimTestAlgo::fenixFormatterEB_
EcalEBFenixStripFormatEB * fenixFormatterEB_
Definition: EcalEBTrigPrimTestAlgo.h:132
EcalEBTrigPrimTestAlgo::clean
void clean(std::vector< std::vector< std::pair< int, std::vector< T > > > > &towerMap)
Definition: EcalEBTrigPrimTestAlgo.h:167
PresampleTask_cfi.nSamples
nSamples
Definition: PresampleTask_cfi.py:7
EcalEBTrigPrimTestAlgo::ecaltpPed_
const EcalTPGPedestals * ecaltpPed_
Definition: EcalEBTrigPrimTestAlgo.h:136
EcalEBTrigPrimTestAlgo::ecaltpgLut_
const EcalTPGLutIdMap * ecaltpgLut_
Definition: EcalEBTrigPrimTestAlgo.h:143
EcalTPGLutGroup
Definition: EcalTPGLutGroup.h:13
EcalEBTrigPrimTestAlgo::nbMaxStrips_
Definition: EcalEBTrigPrimTestAlgo.h:124
EcalEBTrigPrimTestAlgo
Definition: EcalEBTrigPrimTestAlgo.h:37
EcalEBTriggerPrimitiveSample
Definition: EcalEBTriggerPrimitiveSample.h:12
EcalEBTrigPrimTestAlgo::lin_out_
std::vector< std::vector< int > > lin_out_
Definition: EcalEBTrigPrimTestAlgo.h:148
EgammaValidation_cff.samples
samples
Definition: EgammaValidation_cff.py:19
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
EcalEBTrigPrimTestAlgo::tcpformat_out_
std::vector< int > tcpformat_out_
Definition: EcalEBTrigPrimTestAlgo.h:163
EcalEBFenixStripFormatEB.h
CaloGeometry
Definition: CaloGeometry.h:21
EcalTPGSlidingWindow
Definition: EcalTPGSlidingWindow.h:9
debug
#define debug
Definition: HDRShower.cc:19
EcalEBTrigPrimTestAlgo::run
void run(const EBDigiCollection *col, EcalEBTrigPrimDigiCollection &result, EcalEBTrigPrimDigiCollection &resultTcp)
Definition: EcalEBTrigPrimTestAlgo.cc:120
EcalEBFenixTcpFormat.h
EcalEBTrigPrimTestAlgo::maxNrSamples_
int maxNrSamples_
Definition: EcalEBTrigPrimTestAlgo.h:104
EcalEBTrigPrimTestAlgo::debug_
bool debug_
Definition: EcalEBTrigPrimTestAlgo.h:108
EcalEBTrigPrimTestAlgo::towtp2_
std::vector< EcalEBTriggerPrimitiveSample > towtp2_
Definition: EcalEBTrigPrimTestAlgo.h:122
EcalEBTrigPrimTestAlgo::fenixTcpFormat_
EcalEBFenixTcpFormat * fenixTcpFormat_
Definition: EcalEBTrigPrimTestAlgo.h:133
EcalDigiCollections.h
EcalEBTrigPrimTestAlgo::ecaltpgWeightMap_
const EcalTPGWeightIdMap * ecaltpgWeightMap_
Definition: EcalEBTrigPrimTestAlgo.h:139
EcalEBTrigPrimTestAlgo::EcalEBTrigPrimTestAlgo
EcalEBTrigPrimTestAlgo(const EcalTrigTowerConstituentsMap *eTTmap, const CaloGeometry *theGeometry, int nSamples, int binofmax, bool tcpFormat, bool debug, bool famos)
Definition: EcalEBTrigPrimTestAlgo.cc:43
EcalEBTrigPrimTestAlgo::famos_
bool famos_
Definition: EcalEBTrigPrimTestAlgo.h:109
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
EEDetId
Definition: EEDetId.h:14
EcalTPGLutIdMap
Definition: EcalTPGLutIdMap.h:10
EcalEBTrigPrimTestAlgo::ecaltpgLutGroup_
const EcalTPGLutGroup * ecaltpgLutGroup_
Definition: EcalEBTrigPrimTestAlgo.h:142
EcalEBTrigPrimTestAlgo::getLinearizer
EcalEBFenixLinearizer * getLinearizer(int i) const
Definition: EcalEBTrigPrimTestAlgo.h:147
EcalTrigTowerConstituentsMap
Definition: EcalTrigTowerConstituentsMap.h:19
EcalEBTrigPrimTestAlgo::~EcalEBTrigPrimTestAlgo
virtual ~EcalEBTrigPrimTestAlgo()
Definition: EcalEBTrigPrimTestAlgo.cc:111
EcalEBTrigPrimTestAlgo::nrSamples_
static const unsigned int nrSamples_
Definition: EcalEBTrigPrimTestAlgo.h:114
EcalEBTrigPrimTestAlgo::fillMap
void fillMap(Coll const *col, std::vector< std::vector< std::pair< int, std::vector< typename Coll::Digi > > > > &towerMap)
Definition: EcalEBTrigPrimTestAlgo.h:176
EcalEBTrigPrimTestAlgo::peak_out_
std::vector< int > peak_out_
Definition: EcalEBTrigPrimTestAlgo.h:152
EcalEBTrigPrimTestAlgo::towerMapEE_
std::vector< std::vector< std::pair< int, std::vector< EEDataFrame > > > > towerMapEE_
Definition: EcalEBTrigPrimTestAlgo.h:119
EcalEBTrigPrimTestAlgo::linearizer_
std::vector< EcalEBFenixLinearizer * > linearizer_
Definition: EcalEBTrigPrimTestAlgo.h:129
EBDigiCollection
Definition: EcalDigiCollections.h:56
EEDigiCollection
Definition: EcalDigiCollections.h:69
EcalElectronicsMapping.h
EcalEBTrigPrimTestAlgo::ecaltpgSlidW_
const EcalTPGSlidingWindow * ecaltpgSlidW_
Definition: EcalEBTrigPrimTestAlgo.h:141
EcalTriggerElectronicsId.h
EcalEBTrigPrimTestAlgo::towtp_
std::vector< EcalEBTriggerPrimitiveSample > towtp_
Definition: EcalEBTrigPrimTestAlgo.h:121
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
EcalEBTrigPrimTestAlgo::format_out_
std::vector< int > format_out_
Definition: EcalEBTrigPrimTestAlgo.h:153
EcalEBTrigPrimTestAlgo::striptp_
std::vector< std::vector< int > > striptp_
Definition: EcalEBTrigPrimTestAlgo.h:117
EcalEBFenixLinearizer.h
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
EcalEBFenixAmplitudeFilter
calculates .... for Fenix strip, barrel input: 18 bits output: 18 bits
Definition: EcalEBFenixAmplitudeFilter.h:17
EcalEBTrigPrimTestAlgo::maxNrSamplesOut_
static const unsigned int maxNrSamplesOut_
Definition: EcalEBTrigPrimTestAlgo.h:113
EcalEBTrigPrimTestAlgo::getFormatter
EcalEBFenixTcpFormat * getFormatter() const
Definition: EcalEBTrigPrimTestAlgo.h:162
EcalEBTrigPrimTestAlgo::theGeometry_
const CaloGeometry * theGeometry_
Definition: EcalEBTrigPrimTestAlgo.h:99
EcalEBTrigPrimTestAlgo::ecaltpLin_
const EcalTPGLinearizationConst * ecaltpLin_
Definition: EcalEBTrigPrimTestAlgo.h:137
CaloCellGeometry.h
EcalTrigTowerConstituentsMap.h
EcalTPGTowerStatus
Definition: EcalTPGTowerStatus.h:9
EcalEBTrigPrimTestAlgo::hitTowers_
std::vector< std::pair< int, EcalTrigTowerDetId > > hitTowers_
Definition: EcalEBTrigPrimTestAlgo.h:120
EcalEBFenixPeakFinder
calculates the peak for Fenix strip, barrel input : 18 bits output: boolean
Definition: EcalEBFenixPeakFinder.h:16
SortedCollection.h
CaloGeometry.h
EcalEBTrigPrimTestAlgo::peak_finder_
EcalEBFenixPeakFinder * peak_finder_
Definition: EcalEBTrigPrimTestAlgo.h:131
EcalEBTrigPrimTestAlgo::getPeakFinder
EcalEBFenixPeakFinder * getPeakFinder() const
Definition: EcalEBTrigPrimTestAlgo.h:159
EcalEBFenixAmplitudeFilter.h
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
EcalEBTrigPrimTestAlgo::barrelOnly_
bool barrelOnly_
Definition: EcalEBTrigPrimTestAlgo.h:107
mps_fire.result
result
Definition: mps_fire.py:311
EcalEBFenixTcpFormat
Formatting for Fenix Tcp input 10 bits from Ettot 1 bit from fgvb 3 bits TriggerTowerFlag output: 16 ...
Definition: EcalEBFenixTcpFormat.h:22
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
EcalEBTrigPrimTestAlgo::fgvb_out_
std::vector< int > fgvb_out_
Definition: EcalEBTrigPrimTestAlgo.h:155
EcalEBTrigPrimTestAlgo::getFilter
EcalEBFenixAmplitudeFilter * getFilter() const
Definition: EcalEBTrigPrimTestAlgo.h:150
EcalEBTrigPrimTestAlgo::towerMapEB_
std::vector< std::vector< std::pair< int, std::vector< EBDataFrame > > > > towerMapEB_
Definition: EcalEBTrigPrimTestAlgo.h:118
EcalEBTrigPrimTestAlgo::ecaltpgSpike_
const EcalTPGSpike * ecaltpgSpike_
Definition: EcalEBTrigPrimTestAlgo.h:145
EcalEBTrigPrimTestAlgo::ecaltpgBadX_
const EcalTPGCrystalStatus * ecaltpgBadX_
Definition: EcalEBTrigPrimTestAlgo.h:138
EcalEBTrigPrimTestAlgo::getFormatterEB
EcalEBFenixStripFormatEB * getFormatterEB() const
Definition: EcalEBTrigPrimTestAlgo.h:160
EcalEBTrigPrimTestAlgo::ecaltpgWeightGroup_
const EcalTPGWeightGroup * ecaltpgWeightGroup_
Definition: EcalEBTrigPrimTestAlgo.h:140