CMS 3D CMS Logo

EcalEBPhase2TrigPrimAlgo.h
Go to the documentation of this file.
1 #ifndef SimCalorimetry_EcalEBTrigPrimAlgos_EcalEBPhase2TrigPrimAlgo_h
2 #define SimCalorimetry_EcalEBTrigPrimAlgos_EcalEBPhase2TrigPrimAlgo_h
3 
11 #include <sys/time.h>
12 #include <iostream>
13 #include <vector>
14 
20 
30 
36 
37 #include <map>
38 #include <utility>
39 
40 class EcalTrigTowerDetId;
41 class ETPCoherenceTest;
44 class EBDataFrame_Ph2;
45 
47 public:
49  const CaloGeometry *theGeometry,
50  int binofmax,
51  bool debug);
52 
53  virtual ~EcalEBPhase2TrigPrimAlgo();
54 
56 
57  void setPointers(const EcalLiteDTUPedestalsMap *ecaltpPed,
58  const EcalEBPhase2TPGLinearizationConstMap *ecaltpLin,
59  const EcalTPGCrystalStatus *ecaltpgBadX,
60  const EcalEBPhase2TPGAmplWeightIdMap *ecaltpgAmplWeightMap,
61  const EcalEBPhase2TPGTimeWeightIdMap *ecaltpgTimeWeightMap,
62  const EcalTPGWeightGroup *ecaltpgWeightGroup) {
63  ecaltpPed_ = ecaltpPed;
64  ecaltpgBadX_ = ecaltpgBadX;
65  ecaltpLin_ = ecaltpLin;
66  ecaltpgAmplWeightMap_ = ecaltpgAmplWeightMap;
67  ecaltpgTimeWeightMap_ = ecaltpgTimeWeightMap;
68  ecaltpgWeightGroup_ = ecaltpgWeightGroup;
69  }
70 
71 private:
72  //old void init(const edm::EventSetup & setup);
73  void init();
74  template <class T>
75  void initStructures(std::vector<std::vector<std::pair<int, std::vector<T> > > > &towMap);
76  template <class T>
77  void clean(std::vector<std::vector<std::pair<int, std::vector<T> > > > &towerMap);
78 
79  void fillMap(EBDigiCollectionPh2 const *col,
80  std::vector<std::vector<std::pair<int, std::vector<EBDataFrame_Ph2> > > > &towerMap);
81 
82  int findStripNr(const EBDetId &id);
83 
84  int getIndex(const EBDigiCollectionPh2 *, EcalTrigTowerDetId &id) { return id.hashedIndex(); }
85  // mind that eta is continuous between barrel+endcap
86  // int getIndex(const EEDigiCollectionPh2 *, EcalTrigTowerDetId& id) {
87  // int ind=(id.ietaAbs()-18)*72 + id.iphi();
88  // if (id.zside()<0) ind+=792;
89  // return ind;
90  // }
91 
93  const CaloGeometry *theGeometry_ = nullptr;
94 
97  bool debug_;
98 
99  int nrTowers_; // nr of towers found by fillmap method
100  static const unsigned int maxNrTowers_;
101  static const unsigned int nrSamples_;
102 
103  // data structures kept during the whole run
104  std::vector<std::vector<int> > striptp_;
105  std::vector<std::vector<std::pair<int, std::vector<EBDataFrame_Ph2> > > > towerMapEB_;
106  std::vector<std::pair<int, EcalTrigTowerDetId> > hitTowers_;
107  std::vector<EcalEBPhase2TriggerPrimitiveSample> towtp_;
108  std::vector<EcalEBPhase2TriggerPrimitiveSample> towtp2_;
109 
110  enum { nbMaxStrips_ = 5 };
111  enum { nbMaxXtals_ = 5 };
112 
114 
116 
121 
122  //
123 
126 
131 
133  std::vector<int> lin_out_;
134  //
136  std::vector<int> filt_out_;
137  std::vector<int64_t> time_out_;
138  std::vector<int> amp_out_;
139  std::vector<int> outEt_;
140  std::vector<int64_t> outTime_;
141 
145 
146  //
147 };
148 
149 template <class T>
150 void EcalEBPhase2TrigPrimAlgo::clean(std::vector<std::vector<std::pair<int, std::vector<T> > > > &towMap) {
151  // clean internal data structures
152  for (unsigned int i = 0; i < maxNrTowers_; ++i)
153  for (int j = 0; j < nbMaxStrips_; ++j)
154  (towMap[i])[j].first = 0;
155  return;
156 }
157 
159  EBDigiCollectionPh2 const *col, std::vector<std::vector<std::pair<int, std::vector<EBDataFrame_Ph2> > > > &towerMap)
160 
161 {
162  // implementation for Barrel
163  if (col) {
164  nrTowers_ = 0;
165  for (unsigned int i = 0; i < col->size(); ++i) {
167  EcalTrigTowerDetId coarser = (*eTTmap_).towerOf(samples.id());
168  int index = getIndex(col, coarser);
169  EBDetId id = samples.id();
170  int stripnr = findStripNr(id);
171 
172  int filled = 0;
173  for (unsigned int ij = 0; ij < towerMap[index].size(); ++ij)
174  filled += towerMap[index][ij].first;
175  if (!filled) {
176  hitTowers_[nrTowers_++] = std::pair<int, EcalTrigTowerDetId>(index, coarser);
177  }
178 
179  //FIXME: temporary protection
180  int ncryst = towerMap[index][stripnr - 1].first;
181  if (ncryst >= nbMaxXtals_) {
182  continue;
183  }
184  ((towerMap[index])[stripnr - 1].second)[ncryst] = samples;
185  (towerMap[index])[stripnr - 1].first++;
186  }
187 
188  if (debug_)
189  LogDebug("") << "fillMap"
190  << "[EcalEBPhase2TrigPrimAlgo] (found " << col->size() << " frames in " << towerMap.size()
191  << " towers) " << std::endl;
192  } else {
193  if (debug_)
194  LogDebug("EcalEBPhase2TrigPrimAlgo") << "FillMap - FillMap Collection size=0 !!!!" << std::endl;
195  ;
196  }
197 }
198 
199 template <class T>
200 void EcalEBPhase2TrigPrimAlgo::initStructures(std::vector<std::vector<std::pair<int, std::vector<T> > > > &towMap) {
201  //initialise internal data structures
202 
203  std::vector<T> vec0(nbMaxXtals_);
204  std::vector<std::pair<int, std::vector<T> > > vec1(nbMaxStrips_);
205  for (int i = 0; i < nbMaxStrips_; ++i)
206  vec1[i] = std::pair<int, std::vector<T> >(0, vec0);
207  towMap.resize(maxNrTowers_);
208  for (unsigned int i = 0; i < maxNrTowers_; ++i)
209  towMap[i] = vec1;
210 
211  std::vector<int> vecint(maxNrSamples_);
212  striptp_.resize(nbMaxStrips_);
213  for (int i = 0; i < nbMaxStrips_; ++i)
214  striptp_[i] = vecint;
215 }
216 
217 #endif
EcalEBPhase2AmplitudeReconstructor * amplitude_reconstructor_
const EcalEBPhase2TPGTimeWeightIdMap * ecaltpgTimeWeightMap_
const EcalTrigTowerConstituentsMap * eTTmap_
int findStripNr(const EBDetId &id)
int getIndex(const EBDigiCollectionPh2 *, EcalTrigTowerDetId &id)
std::vector< std::pair< int, EcalTrigTowerDetId > > hitTowers_
static const unsigned int nrSamples_
U second(std::pair< T, U > const &p)
EcalEBPhase2TimeReconstructor * getTimeFinder() const
void setPointers(const EcalLiteDTUPedestalsMap *ecaltpPed, const EcalEBPhase2TPGLinearizationConstMap *ecaltpLin, const EcalTPGCrystalStatus *ecaltpgBadX, const EcalEBPhase2TPGAmplWeightIdMap *ecaltpgAmplWeightMap, const EcalEBPhase2TPGTimeWeightIdMap *ecaltpgTimeWeightMap, const EcalTPGWeightGroup *ecaltpgWeightGroup)
std::vector< double > vec1
Definition: HCALResponse.h:15
void run(const EBDigiCollectionPh2 *col, EcalEBPhase2TrigPrimDigiCollection &result)
const EcalTPGWeightGroup * ecaltpgWeightGroup_
static const unsigned int maxNrTowers_
std::vector< EcalEBPhase2TriggerPrimitiveSample > towtp_
EcalEBPhase2TimeReconstructor * time_reconstructor_
std::vector< int64_t > outTime_
EcalEBPhase2Linearizer * linearizer_
#define debug
Definition: HDRShower.cc:19
const EcalTPGCrystalStatus * ecaltpgBadX_
EcalEBPhase2Linearizer * getLinearizer() const
std::vector< std::vector< std::pair< int, std::vector< EBDataFrame_Ph2 > > > > towerMapEB_
EcalEBPhase2SpikeTagger * spike_tagger_
const EcalEBPhase2TPGLinearizationConstMap * ecaltpLin_
std::vector< int64_t > time_out_
const EcalLiteDTUPedestalsMap * ecaltpPed_
EcalEBPhase2TrigPrimAlgo(const EcalTrigTowerConstituentsMap *eTTmap, const CaloGeometry *theGeometry, int binofmax, bool debug)
col
Definition: cuy.py:1009
const EcalElectronicsMapping * theMapping_
const CaloGeometry * theGeometry_
void initStructures(std::vector< std::vector< std::pair< int, std::vector< T > > > > &towMap)
EcalEBPhase2AmplitudeReconstructor * getAmplitudeFinder() const
void clean(std::vector< std::vector< std::pair< int, std::vector< T > > > > &towerMap)
EcalEBPhase2TPFormatter * tpFormatter_
EcalEBPhase2SpikeTagger * getSpikeTagger() const
const EcalEBPhase2TPGAmplWeightIdMap * ecaltpgAmplWeightMap_
EcalEBPhase2TPFormatter * getTPFormatter() const
std::vector< std::vector< int > > striptp_
std::vector< EcalEBPhase2TriggerPrimitiveSample > towtp2_
void fillMap(EBDigiCollectionPh2 const *col, std::vector< std::vector< std::pair< int, std::vector< EBDataFrame_Ph2 > > > > &towerMap)
#define LogDebug(id)