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 
28 
29 
35 
36 #include <map>
37 #include <utility>
38 
39 
40 class EcalTrigTowerDetId;
41 class ETPCoherenceTest;
44 class EBDataFrame;
45 
46 
47 
49 {
50  public:
51 
52  explicit EcalEBTrigPrimTestAlgo(const edm::EventSetup & setup, int nSamples, int binofmax, bool tcpFormat, bool barrelOnly, bool debug, bool famos);
53 
54  virtual ~EcalEBTrigPrimTestAlgo();
55 
56 
57  // void run(const edm::EventSetup &, const EcalRecHitCollection *col, EcalEBTrigPrimDigiCollection & result, EcalEBTrigPrimDigiCollection & resultTcp);
59 
60  void setPointers(const EcalTPGLinearizationConst *ecaltpLin,
61  const EcalTPGPedestals *ecaltpPed,
62  const EcalTPGCrystalStatus * ecaltpgBadX,
63  const EcalTPGWeightIdMap *ecaltpgWeightMap,
64  const EcalTPGWeightGroup *ecaltpgWeightGroup,
65  const EcalTPGSlidingWindow* ecaltpgSlidW,
66  const EcalTPGLutGroup *ecaltpgLutGroup,
67  const EcalTPGLutIdMap *ecaltpgLut,
68  const EcalTPGTowerStatus *ecaltpgBadTT,
69  const EcalTPGSpike * ecaltpgSpike )
70 {
71  ecaltpPed_=ecaltpPed;
72  ecaltpLin_=ecaltpLin;
73  ecaltpgBadX_=ecaltpgBadX;
74  ecaltpgWeightMap_=ecaltpgWeightMap;
75  ecaltpgWeightGroup_=ecaltpgWeightGroup;
76  ecaltpgSlidW_=ecaltpgSlidW;
77  ecaltpgLutGroup_=ecaltpgLutGroup;
78  ecaltpgLut_=ecaltpgLut;
79  ecaltpgBadTT_=ecaltpgBadTT;
80  ecaltpgSpike_= ecaltpgSpike;
81  }
82 
83 
84  private:
85 
86  void init(const edm::EventSetup&);
87  template <class T>
88  void initStructures(std::vector<std::vector<std::pair<int,std::vector<T> > > > & towMap);
89  template <class T>
90  void clean(std::vector<std::vector<std::pair<int,std::vector<T> > > > &towerMap);
91  template <class Coll>
92  void fillMap(Coll const * col, std::vector<std::vector<std::pair<int,std::vector<typename Coll::Digi> > > > &towerMap);
93  int findStripNr(const EBDetId &id);
94  int findStripNr(const EEDetId &id);
95 
96  // FIXME: temporary until hashedIndex works alsom for endcap
97  int getIndex(const EBDigiCollection *, EcalTrigTowerDetId& id) {return id.hashedIndex();}
98  // mind that eta is continuous between barrel+endcap
100  int ind=(id.ietaAbs()-18)*72 + id.iphi();
101  if (id.zside()<0) ind+=792;
102  return ind;
103  }
104 
106  // const CaloSubdetectorGeometry *theEndcapGeometry;
108 
109 
110  float threshold;
114 
115 
118  bool debug_;
119  bool famos_;
120 
121 
122  int nrTowers_; // nr of towers found by fillmap method
123  static const unsigned int maxNrTowers_;
124  static const unsigned int maxNrSamplesOut_;
125  static const unsigned int nrSamples_;
126 
127  // data structures kept during the whole run
128  std::vector<std::vector<int> > striptp_;
129  std::vector<std::vector<std::pair<int,std::vector<EBDataFrame> > > > towerMapEB_;
130  std::vector<std::vector<std::pair<int,std::vector<EEDataFrame> > > > towerMapEE_;
131  std::vector<std::pair<int,EcalTrigTowerDetId> > hitTowers_;
132  std::vector<EcalEBTriggerPrimitiveSample> towtp_;
133  std::vector<EcalEBTriggerPrimitiveSample> towtp2_;
134 
135  enum {nbMaxStrips_=5};
136  enum {nbMaxXtals_=5};
137 
139 
140 
141  std::vector <EcalFenixLinearizer *> linearizer_;
146 
147  //
158 
159 
160  EcalFenixLinearizer *getLinearizer (int i) const { return linearizer_[i];}
161  std::vector<std::vector<int> > lin_out_;
162  //
164  std::vector<int> filt_out_;
165  std::vector<int> peak_out_;
166  std::vector<int> format_out_;
167  // these two are dummy
168  std::vector<int> fgvb_out_;
169  std::vector<int> fgvb_out_temp_;
170 
171  //
174  //
176  std::vector<int> tcpformat_out_;
177 
178 
179 
180 };
181 
182 
183 template <class T>
184 void EcalEBTrigPrimTestAlgo::clean( std::vector<std::vector<std::pair<int,std::vector<T> > > > & towMap) {
185  // clean internal data structures
186  for (unsigned int i=0;i<maxNrTowers_;++i)
187  for (int j=0;j<nbMaxStrips_ ;++j) (towMap[i])[j].first=0;
188  return;
189 }
190 
191 
192 template <class Coll>
194  std::vector<std::vector<std::pair<int,std::vector<typename Coll::Digi> > > > &towerMap)
195 {
196  typedef typename Coll::Digi Digi;
197 
198  // implementation for Barrel
199  if (col) {
200  nrTowers_=0;
201  if ( debug_) std::cout <<"Fill mapping, Collection size = "<< col->size() << std::endl;;
202  for(unsigned int i = 0; i < col->size() ; ++i) {
203  Digi samples((*col)[i]);
204  EcalTrigTowerDetId coarser=(*eTTmap_).towerOf(samples.id());
205  int index=getIndex(col,coarser);
206  int stripnr=findStripNr(samples.id());
207 
208  int filled=0;
209  for (unsigned int ij=0;ij<towerMap[index].size();++ij) filled+=towerMap[index][ij].first;
210  if (!filled) {
211  hitTowers_[nrTowers_++]=std::pair <int,EcalTrigTowerDetId>(index,coarser);
212  }
213 
214  //FIXME: temporary protection
215  int ncryst=towerMap[index][stripnr-1].first;
216  if (ncryst>=nbMaxXtals_ ) {
217  edm::LogError("EcalTrigPrimFunctionAlgo")<<"! Too many xtals for TT "<<coarser<<" stripnr "<<stripnr<<" xtalid "<<samples.id() ;
218  continue;
219  }
220  ((towerMap[index])[stripnr-1].second)[ncryst]=samples;
221  (towerMap[index])[stripnr-1].first++;
222  }
223 
224  if (debug_) std::cout << "fillMap"<<"[EcalTrigPrimFunctionalAlgo] (found "
225  << col->size() << " frames in "<< towerMap.size() << " towers) " << std::endl;
226  }
227  else {
228  if (debug_) std::cout <<"FillMap - FillMap Collection size=0 !!!!" << std::endl;;
229  }
230 }
231 
232 template <class T>
233 void EcalEBTrigPrimTestAlgo::initStructures( std::vector<std::vector<std::pair<int,std::vector<T> > > > & towMap) {
234  //initialise internal data structures
235 
236  std::vector <T> vec0(nbMaxXtals_ );
237  std::vector<std::pair<int,std::vector<T> > > vec1(nbMaxStrips_);
238  for (int i=0;i<nbMaxStrips_ ;++i) vec1[i]=std::pair<int,std::vector<T> >(0,vec0);
239  towMap.resize(maxNrTowers_);
240  for (unsigned int i=0;i<maxNrTowers_;++i) towMap[i]=vec1;
241 
242  std::vector<int> vecint(maxNrSamples_);
243  striptp_.resize(nbMaxStrips_);
244  for (int i=0;i<nbMaxStrips_;++i) striptp_[i]=vecint;
245 
246 }
247 
248 
249 
250 #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
int zside(DetId 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_