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