CMS 3D CMS Logo

EcalEBTrigPrimTestAlgo.h
Go to the documentation of this file.
1 #ifndef EcalEBTrigPrimTestAlgo_h
2 #define EcalEBTrigPrimTestAlgo_h
3 
9 #include <sys/time.h>
10 #include <iostream>
11 #include <vector>
12 
17 //#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
19 
27 
33 
34 #include <map>
35 #include <utility>
36 
37 class EcalTrigTowerDetId;
38 class ETPCoherenceTest;
41 class EBDataFrame;
42 
44 public:
45  explicit EcalEBTrigPrimTestAlgo(
46  const edm::EventSetup &setup, int nSamples, int binofmax, bool tcpFormat, bool barrelOnly, bool debug, bool famos);
47 
48  virtual ~EcalEBTrigPrimTestAlgo();
49 
50  // void run(const edm::EventSetup &, const EcalRecHitCollection *col, EcalEBTrigPrimDigiCollection & result, EcalEBTrigPrimDigiCollection & resultTcp);
51  void run(const edm::EventSetup &,
52  const EBDigiCollection *col,
54  EcalEBTrigPrimDigiCollection &resultTcp);
55 
56  void setPointers(const EcalTPGLinearizationConst *ecaltpLin,
57  const EcalTPGPedestals *ecaltpPed,
58  const EcalTPGCrystalStatus *ecaltpgBadX,
59  const EcalTPGWeightIdMap *ecaltpgWeightMap,
60  const EcalTPGWeightGroup *ecaltpgWeightGroup,
61  const EcalTPGSlidingWindow *ecaltpgSlidW,
62  const EcalTPGLutGroup *ecaltpgLutGroup,
63  const EcalTPGLutIdMap *ecaltpgLut,
64  const EcalTPGTowerStatus *ecaltpgBadTT,
65  const EcalTPGSpike *ecaltpgSpike) {
66  ecaltpPed_ = ecaltpPed;
67  ecaltpLin_ = ecaltpLin;
68  ecaltpgBadX_ = ecaltpgBadX;
69  ecaltpgWeightMap_ = ecaltpgWeightMap;
70  ecaltpgWeightGroup_ = ecaltpgWeightGroup;
71  ecaltpgSlidW_ = ecaltpgSlidW;
72  ecaltpgLutGroup_ = ecaltpgLutGroup;
73  ecaltpgLut_ = ecaltpgLut;
74  ecaltpgBadTT_ = ecaltpgBadTT;
75  ecaltpgSpike_ = ecaltpgSpike;
76  }
77 
78 private:
79  void init(const edm::EventSetup &);
80  template <class T>
81  void initStructures(std::vector<std::vector<std::pair<int, std::vector<T> > > > &towMap);
82  template <class T>
83  void clean(std::vector<std::vector<std::pair<int, std::vector<T> > > > &towerMap);
84  template <class Coll>
85  void fillMap(Coll const *col,
86  std::vector<std::vector<std::pair<int, std::vector<typename Coll::Digi> > > > &towerMap);
87  int findStripNr(const EBDetId &id);
88  int findStripNr(const EEDetId &id);
89 
90  // FIXME: temporary until hashedIndex works alsom for endcap
91  int getIndex(const EBDigiCollection *, EcalTrigTowerDetId &id) { return id.hashedIndex(); }
92  // mind that eta is continuous between barrel+endcap
94  int ind = (id.ietaAbs() - 18) * 72 + id.iphi();
95  if (id.zside() < 0)
96  ind += 792;
97  return ind;
98  }
99 
101  // const CaloSubdetectorGeometry *theEndcapGeometry;
103 
104  float threshold;
108 
111  bool debug_;
112  bool famos_;
113 
114  int nrTowers_; // nr of towers found by fillmap method
115  static const unsigned int maxNrTowers_;
116  static const unsigned int maxNrSamplesOut_;
117  static const unsigned int nrSamples_;
118 
119  // data structures kept during the whole run
120  std::vector<std::vector<int> > striptp_;
121  std::vector<std::vector<std::pair<int, std::vector<EBDataFrame> > > > towerMapEB_;
122  std::vector<std::vector<std::pair<int, std::vector<EEDataFrame> > > > towerMapEE_;
123  std::vector<std::pair<int, EcalTrigTowerDetId> > hitTowers_;
124  std::vector<EcalEBTriggerPrimitiveSample> towtp_;
125  std::vector<EcalEBTriggerPrimitiveSample> towtp2_;
126 
127  enum { nbMaxStrips_ = 5 };
128  enum { nbMaxXtals_ = 5 };
129 
131 
132  std::vector<EcalFenixLinearizer *> linearizer_;
137 
138  //
149 
151  std::vector<std::vector<int> > lin_out_;
152  //
154  std::vector<int> filt_out_;
155  std::vector<int> peak_out_;
156  std::vector<int> format_out_;
157  // these two are dummy
158  std::vector<int> fgvb_out_;
159  std::vector<int> fgvb_out_temp_;
160 
161  //
164  //
166  std::vector<int> tcpformat_out_;
167 };
168 
169 template <class T>
170 void EcalEBTrigPrimTestAlgo::clean(std::vector<std::vector<std::pair<int, std::vector<T> > > > &towMap) {
171  // clean internal data structures
172  for (unsigned int i = 0; i < maxNrTowers_; ++i)
173  for (int j = 0; j < nbMaxStrips_; ++j)
174  (towMap[i])[j].first = 0;
175  return;
176 }
177 
178 template <class Coll>
180  Coll const *col, std::vector<std::vector<std::pair<int, std::vector<typename Coll::Digi> > > > &towerMap) {
181  typedef typename Coll::Digi Digi;
182 
183  // implementation for Barrel
184  if (col) {
185  nrTowers_ = 0;
186  if (debug_)
187  std::cout << "Fill mapping, Collection size = " << col->size() << std::endl;
188  ;
189  for (unsigned int i = 0; i < col->size(); ++i) {
190  Digi samples((*col)[i]);
191  EcalTrigTowerDetId coarser = (*eTTmap_).towerOf(samples.id());
192  int index = getIndex(col, coarser);
193  int stripnr = findStripNr(samples.id());
194 
195  int filled = 0;
196  for (unsigned int ij = 0; ij < towerMap[index].size(); ++ij)
197  filled += towerMap[index][ij].first;
198  if (!filled) {
199  hitTowers_[nrTowers_++] = std::pair<int, EcalTrigTowerDetId>(index, coarser);
200  }
201 
202  //FIXME: temporary protection
203  int ncryst = towerMap[index][stripnr - 1].first;
204  if (ncryst >= nbMaxXtals_) {
205  edm::LogError("EcalTrigPrimFunctionAlgo")
206  << "! Too many xtals for TT " << coarser << " stripnr " << stripnr << " xtalid " << samples.id();
207  continue;
208  }
209  ((towerMap[index])[stripnr - 1].second)[ncryst] = samples;
210  (towerMap[index])[stripnr - 1].first++;
211  }
212 
213  if (debug_)
214  std::cout << "fillMap"
215  << "[EcalTrigPrimFunctionalAlgo] (found " << col->size() << " frames in " << towerMap.size()
216  << " towers) " << std::endl;
217  } else {
218  if (debug_)
219  std::cout << "FillMap - FillMap Collection size=0 !!!!" << std::endl;
220  ;
221  }
222 }
223 
224 template <class T>
225 void EcalEBTrigPrimTestAlgo::initStructures(std::vector<std::vector<std::pair<int, std::vector<T> > > > &towMap) {
226  //initialise internal data structures
227 
228  std::vector<T> vec0(nbMaxXtals_);
229  std::vector<std::pair<int, std::vector<T> > > vec1(nbMaxStrips_);
230  for (int i = 0; i < nbMaxStrips_; ++i)
231  vec1[i] = std::pair<int, std::vector<T> >(0, vec0);
232  towMap.resize(maxNrTowers_);
233  for (unsigned int i = 0; i < maxNrTowers_; ++i)
234  towMap[i] = vec1;
235 
236  std::vector<int> vecint(maxNrSamples_);
237  striptp_.resize(nbMaxStrips_);
238  for (int i = 0; i < nbMaxStrips_; ++i)
239  striptp_[i] = vecint;
240 }
241 
242 #endif
EcalEBTrigPrimTestAlgo::nSamples_
int nSamples_
Definition: EcalEBTrigPrimTestAlgo.h:105
EcalEBTrigPrimTestAlgo::nrTowers_
int nrTowers_
Definition: EcalEBTrigPrimTestAlgo.h:114
EcalEBTrigPrimTestAlgo::binOfMaximum_
int binOfMaximum_
Definition: EcalEBTrigPrimTestAlgo.h:106
EcalElectronicsMapping
Definition: EcalElectronicsMapping.h:28
EcalTPGWeightIdMap
Definition: EcalTPGWeightIdMap.h:10
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
EcalEBTrigPrimTestAlgo::maxNrTowers_
static const unsigned int maxNrTowers_
Definition: EcalEBTrigPrimTestAlgo.h:115
EcalEBTrigPrimTestAlgo::tcpFormat_
bool tcpFormat_
Definition: EcalEBTrigPrimTestAlgo.h:109
EcalEBTrigPrimTestAlgo::ecaltpgBadTT_
const EcalTPGTowerStatus * ecaltpgBadTT_
Definition: EcalEBTrigPrimTestAlgo.h:147
ESHandle.h
vec1
std::vector< double > vec1
Definition: HCALResponse.h:15
EcalFenixLinearizer.h
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:56
EcalFenixAmplitudeFilter.h
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
EcalFenixPeakFinder
calculates the peak for Fenix strip, barrel input : 18 bits output: boolean
Definition: EcalFenixPeakFinder.h:16
EcalEBTrigPrimTestAlgo::run
void run(const edm::EventSetup &, const EBDigiCollection *col, EcalEBTrigPrimDigiCollection &result, EcalEBTrigPrimDigiCollection &resultTcp)
Definition: EcalEBTrigPrimTestAlgo.cc:105
EcalEBTrigPrimTestAlgo::threshold
float threshold
Definition: EcalEBTrigPrimTestAlgo.h:104
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:159
EcalEBTrigPrimTestAlgo::findStripNr
int findStripNr(const EBDetId &id)
Definition: EcalEBTrigPrimTestAlgo.cc:305
EcalEBTrigPrimTestAlgo::eTTmap_
edm::ESHandle< EcalTrigTowerConstituentsMap > eTTmap_
Definition: EcalEBTrigPrimTestAlgo.h:100
EcalEBTrigPrimTestAlgo::getIndex
int getIndex(const EEDigiCollection *, EcalTrigTowerDetId &id)
Definition: EcalEBTrigPrimTestAlgo.h:93
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
EcalEBTrigPrimTestAlgo::theGeometry
edm::ESHandle< CaloGeometry > theGeometry
Definition: EcalEBTrigPrimTestAlgo.h:102
EcalEBTrigPrimTestAlgo::initStructures
void initStructures(std::vector< std::vector< std::pair< int, std::vector< T > > > > &towMap)
Definition: EcalEBTrigPrimTestAlgo.h:225
EcalTPGWeightGroup
Definition: EcalTPGWeightGroup.h:13
EcalEBTrigPrimTestAlgo::getFormatterEB
EcalFenixStripFormatEB * getFormatterEB() const
Definition: EcalEBTrigPrimTestAlgo.h:163
EcalEBTrigPrimTestAlgo::getIndex
int getIndex(const EBDigiCollection *, EcalTrigTowerDetId &id)
Definition: EcalEBTrigPrimTestAlgo.h:91
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
EcalEBTrigPrimTestAlgo::theMapping_
const EcalElectronicsMapping * theMapping_
Definition: EcalEBTrigPrimTestAlgo.h:130
EcalEBTrigPrimTestAlgo::filt_out_
std::vector< int > filt_out_
Definition: EcalEBTrigPrimTestAlgo.h:154
dqmdumpme.first
first
Definition: dqmdumpme.py:55
EcalEBTrigPrimTestAlgo::clean
void clean(std::vector< std::vector< std::pair< int, std::vector< T > > > > &towerMap)
Definition: EcalEBTrigPrimTestAlgo.h:170
PresampleTask_cfi.nSamples
nSamples
Definition: PresampleTask_cfi.py:7
EcalEBTrigPrimTestAlgo::ecaltpPed_
const EcalTPGPedestals * ecaltpPed_
Definition: EcalEBTrigPrimTestAlgo.h:139
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
EcalEBTrigPrimTestAlgo::ecaltpgLut_
const EcalTPGLutIdMap * ecaltpgLut_
Definition: EcalEBTrigPrimTestAlgo.h:146
EcalTPGLutGroup
Definition: EcalTPGLutGroup.h:13
EcalEBTrigPrimTestAlgo::getPeakFinder
EcalFenixPeakFinder * getPeakFinder() const
Definition: EcalEBTrigPrimTestAlgo.h:162
EcalEBTrigPrimTestAlgo::nbMaxStrips_
Definition: EcalEBTrigPrimTestAlgo.h:127
EcalEBTrigPrimTestAlgo
Definition: EcalEBTrigPrimTestAlgo.h:43
EcalEBTriggerPrimitiveSample
Definition: EcalEBTriggerPrimitiveSample.h:12
EcalEBTrigPrimTestAlgo::lin_out_
std::vector< std::vector< int > > lin_out_
Definition: EcalEBTrigPrimTestAlgo.h:151
EgammaValidation_cff.samples
samples
Definition: EgammaValidation_cff.py:19
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
EcalEBTrigPrimTestAlgo::linearizer_
std::vector< EcalFenixLinearizer * > linearizer_
Definition: EcalEBTrigPrimTestAlgo.h:132
EcalFenixStripFormatEB.h
EcalEBTrigPrimTestAlgo::tcpformat_out_
std::vector< int > tcpformat_out_
Definition: EcalEBTrigPrimTestAlgo.h:166
EcalEBTrigPrimTestAlgo::fenixTcpFormat_
EcalFenixTcpFormat * fenixTcpFormat_
Definition: EcalEBTrigPrimTestAlgo.h:136
EcalTPGSlidingWindow
Definition: EcalTPGSlidingWindow.h:9
debug
#define debug
Definition: HDRShower.cc:19
EcalEBTrigPrimTestAlgo::maxNrSamples_
int maxNrSamples_
Definition: EcalEBTrigPrimTestAlgo.h:107
EcalEBTrigPrimTestAlgo::peak_finder_
EcalFenixPeakFinder * peak_finder_
Definition: EcalEBTrigPrimTestAlgo.h:134
EcalEBTrigPrimTestAlgo::debug_
bool debug_
Definition: EcalEBTrigPrimTestAlgo.h:111
EcalEBTrigPrimTestAlgo::towtp2_
std::vector< EcalEBTriggerPrimitiveSample > towtp2_
Definition: EcalEBTrigPrimTestAlgo.h:125
EcalDigiCollections.h
edm::ESHandle< EcalTrigTowerConstituentsMap >
EcalEBTrigPrimTestAlgo::ecaltpgWeightMap_
const EcalTPGWeightIdMap * ecaltpgWeightMap_
Definition: EcalEBTrigPrimTestAlgo.h:142
EcalEBTrigPrimTestAlgo::famos_
bool famos_
Definition: EcalEBTrigPrimTestAlgo.h:112
EEDetId
Definition: EEDetId.h:14
CaloGeometryRecord.h
EcalTPGLutIdMap
Definition: EcalTPGLutIdMap.h:10
EcalEBTrigPrimTestAlgo::ecaltpgLutGroup_
const EcalTPGLutGroup * ecaltpgLutGroup_
Definition: EcalEBTrigPrimTestAlgo.h:145
EcalEBTrigPrimTestAlgo::amplitude_filter_
EcalFenixAmplitudeFilter * amplitude_filter_
Definition: EcalEBTrigPrimTestAlgo.h:133
EcalEBTrigPrimTestAlgo::~EcalEBTrigPrimTestAlgo
virtual ~EcalEBTrigPrimTestAlgo()
Definition: EcalEBTrigPrimTestAlgo.cc:96
CaloSubdetectorGeometry.h
EcalEBTrigPrimTestAlgo::nrSamples_
static const unsigned int nrSamples_
Definition: EcalEBTrigPrimTestAlgo.h:117
EcalEBTrigPrimTestAlgo::fillMap
void fillMap(Coll const *col, std::vector< std::vector< std::pair< int, std::vector< typename Coll::Digi > > > > &towerMap)
Definition: EcalEBTrigPrimTestAlgo.h:179
EcalEBTrigPrimTestAlgo::peak_out_
std::vector< int > peak_out_
Definition: EcalEBTrigPrimTestAlgo.h:155
EcalEBTrigPrimTestAlgo::towerMapEE_
std::vector< std::vector< std::pair< int, std::vector< EEDataFrame > > > > towerMapEE_
Definition: EcalEBTrigPrimTestAlgo.h:122
EcalEBTrigPrimTestAlgo::init
void init(const edm::EventSetup &)
Definition: EcalEBTrigPrimTestAlgo.cc:57
EBDigiCollection
Definition: EcalDigiCollections.h:56
EEDigiCollection
Definition: EcalDigiCollections.h:69
EcalElectronicsMapping.h
EcalEBTrigPrimTestAlgo::nbMaxXtals_
Definition: EcalEBTrigPrimTestAlgo.h:128
EcalEBTrigPrimTestAlgo::ecaltpgSlidW_
const EcalTPGSlidingWindow * ecaltpgSlidW_
Definition: EcalEBTrigPrimTestAlgo.h:144
EcalFenixLinearizer
Linearisation for Fenix strip input: 16 bits corresponding to input EBDataFrame output: 18 bits.
Definition: EcalFenixLinearizer.h:19
EcalTriggerElectronicsId.h
EcalEBTrigPrimTestAlgo::fenixFormatterEB_
EcalFenixStripFormatEB * fenixFormatterEB_
Definition: EcalEBTrigPrimTestAlgo.h:135
EcalEBTrigPrimTestAlgo::getFormatter
EcalFenixTcpFormat * getFormatter() const
Definition: EcalEBTrigPrimTestAlgo.h:165
EcalEBTrigPrimTestAlgo::towtp_
std::vector< EcalEBTriggerPrimitiveSample > towtp_
Definition: EcalEBTrigPrimTestAlgo.h:124
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
EcalEBTrigPrimTestAlgo::EcalEBTrigPrimTestAlgo
EcalEBTrigPrimTestAlgo(const edm::EventSetup &setup, int nSamples, int binofmax, bool tcpFormat, bool barrelOnly, bool debug, bool famos)
Definition: EcalEBTrigPrimTestAlgo.cc:42
EcalEBTrigPrimTestAlgo::format_out_
std::vector< int > format_out_
Definition: EcalEBTrigPrimTestAlgo.h:156
edm::EventSetup
Definition: EventSetup.h:57
EcalEBTrigPrimTestAlgo::striptp_
std::vector< std::vector< int > > striptp_
Definition: EcalEBTrigPrimTestAlgo.h:120
EcalFenixTcpFormat.h
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
EcalEBTrigPrimTestAlgo::maxNrSamplesOut_
static const unsigned int maxNrSamplesOut_
Definition: EcalEBTrigPrimTestAlgo.h:116
EcalEBTrigPrimTestAlgo::ecaltpLin_
const EcalTPGLinearizationConst * ecaltpLin_
Definition: EcalEBTrigPrimTestAlgo.h:140
CaloCellGeometry.h
EcalTrigTowerConstituentsMap.h
EcalTPGTowerStatus
Definition: EcalTPGTowerStatus.h:9
EcalFenixPeakFinder.h
EcalEBTrigPrimTestAlgo::hitTowers_
std::vector< std::pair< int, EcalTrigTowerDetId > > hitTowers_
Definition: EcalEBTrigPrimTestAlgo.h:123
EcalEBTrigPrimTestAlgo::getLinearizer
EcalFenixLinearizer * getLinearizer(int i) const
Definition: EcalEBTrigPrimTestAlgo.h:150
SortedCollection.h
EcalFenixAmplitudeFilter
calculates .... for Fenix strip, barrel input: 18 bits output: 18 bits
Definition: EcalFenixAmplitudeFilter.h:17
CaloGeometry.h
EcalFenixTcpFormat
Definition: EcalFenixTcpFormat.h:22
EventSetup.h
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
EcalEBTrigPrimTestAlgo::barrelOnly_
bool barrelOnly_
Definition: EcalEBTrigPrimTestAlgo.h:110
mps_fire.result
result
Definition: mps_fire.py:311
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
EcalEBTrigPrimTestAlgo::fgvb_out_
std::vector< int > fgvb_out_
Definition: EcalEBTrigPrimTestAlgo.h:158
EcalEBTrigPrimTestAlgo::towerMapEB_
std::vector< std::vector< std::pair< int, std::vector< EBDataFrame > > > > towerMapEB_
Definition: EcalEBTrigPrimTestAlgo.h:121
EcalFenixStripFormatEB
Formatting for Fenix strip input: 18 bits + 3x 1bit (fgvb, gapflagbit, output from peakfinder) output...
Definition: EcalFenixStripFormatEB.h:18
EcalEBTrigPrimTestAlgo::getFilter
EcalFenixAmplitudeFilter * getFilter() const
Definition: EcalEBTrigPrimTestAlgo.h:153
EcalEBTrigPrimTestAlgo::ecaltpgSpike_
const EcalTPGSpike * ecaltpgSpike_
Definition: EcalEBTrigPrimTestAlgo.h:148
EcalEBTrigPrimTestAlgo::ecaltpgBadX_
const EcalTPGCrystalStatus * ecaltpgBadX_
Definition: EcalEBTrigPrimTestAlgo.h:141
EcalEBTrigPrimTestAlgo::ecaltpgWeightGroup_
const EcalTPGWeightGroup * ecaltpgWeightGroup_
Definition: EcalEBTrigPrimTestAlgo.h:143