test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HtrXmlPatternSet.cc
Go to the documentation of this file.
1 #include "HtrXmlPatternSet.h"
2 #include <math.h>
3 #include <iostream>
4 
6  for (int i=0; i<SAMPLES; i++) {
7  fCReal[i]=0;
8  fCCoded[i]=0;
9  fCQuantized[i]=0;
10  }
11  m_sample_pos=0;
12 }
13 
14 void ChannelPattern::Fill_by_hand(const HcalElectronicsMap *emap,int pattern_number) {
15 
16  for (int iSample=0;iSample<SAMPLES;iSample++) {
17  fCCoded [iSample]=0;
18  fCQuantized[iSample]=0;
19  }
20 
21  int dcc9[NUM_CRATES];
22  int dcc19[NUM_CRATES];
23  for (int jCrate=0;jCrate<NUM_CRATES;jCrate++) {
24  dcc9[jCrate]=-1;
25  dcc19[jCrate]=-1;
26  }
27 
28  int iCrate;
29  iCrate=4 ; dcc9[iCrate]=700; dcc19[iCrate]=701;
30  iCrate=0 ; dcc9[iCrate]=702; dcc19[iCrate]=703;
31  iCrate=1 ; dcc9[iCrate]=704; dcc19[iCrate]=705;
32  iCrate=5 ; dcc9[iCrate]=706; dcc19[iCrate]=707;
33  iCrate=11; dcc9[iCrate]=708; dcc19[iCrate]=709;
34  iCrate=15; dcc9[iCrate]=710; dcc19[iCrate]=711;
35  iCrate=17; dcc9[iCrate]=712; dcc19[iCrate]=713;
36  iCrate=14; dcc9[iCrate]=714; dcc19[iCrate]=715;
37  iCrate=10; dcc9[iCrate]=716; dcc19[iCrate]=717;
38  iCrate=2 ; dcc9[iCrate]=718; dcc19[iCrate]=719;
39  iCrate=9 ; dcc9[iCrate]=720; dcc19[iCrate]=721;
40  iCrate=12; dcc9[iCrate]=722; dcc19[iCrate]=723;
41  iCrate=3 ; dcc9[iCrate]=724; dcc19[iCrate]=725;
42  iCrate=7 ; dcc9[iCrate]=726; dcc19[iCrate]=727;
43  iCrate=6 ; dcc9[iCrate]=728; dcc19[iCrate]=729;
44  iCrate=13; dcc9[iCrate]=730; dcc19[iCrate]=731;
45 
46  int *dcc=0;
47  int spigot=-100;
48  if (m_slot>=2 && m_slot<=8) {
49  spigot=2*m_slot-m_tb-3;
50  dcc=dcc9;
51  }
52  else if (m_slot>=13 && m_slot<=18) {
53  spigot=2*m_slot-m_tb-25;
54  dcc=dcc19;
55  }
56  else return;
57 
58  int fiber_channel=(m_chan-1)%3;
59  int fiber=(m_chan-fiber_channel-1)/3 +1;
60  int dcc_num=dcc[m_crate]-700;
61 
62  HcalElectronicsId heid(fiber_channel,fiber,spigot,dcc_num);
63  heid.setHTR(m_crate,m_slot,m_tb);
64 
65  //if (heid.readoutVMECrateId()!=m_crate) std::cout << "crate: " << heid.readoutVMECrateId() << "; " << m_crate << std::endl;
66  //if (heid.htrSlot()!=m_slot) std::cout << "slot: " << heid.htrSlot() << "; " << m_slot << std::endl;
67  //if (heid.htrTopBottom()!=m_tb) std::cout << "tb: " << heid.htrTopBottom() << "; " << m_tb << std::endl;
68  //if (heid.htrChanId()!=m_chan) std::cout << "chan: " << heid.htrChanId() << "; " << m_chan << std::endl;
69  //
70  //if (heid.readoutVMECrateId()==14 && heid.htrTopBottom()==0 && heid.htrChanId()==3) {
71  // std::cout << heid.rawId() << " " << heid << std::endl;
72  //}
73 
74  try {
75  const HcalDetId hdid=emap->lookup(heid);
76 
77  int etaabs=hdid.ietaAbs();
78  int phi=hdid.iphi();
79  int side=hdid.zside();
80  int depth=hdid.depth();
81  int subdet=hdid.subdet();
82 
84  if (pattern_number==1) {
85  if (m_crate==2 || m_crate==9 || m_crate==12) return;
86  //fill only one channel per half-crate
87  if (m_slot!=2 && m_slot!=13) return;
88  if (m_tb!=0) return;
89  if (m_chan!=5) return;
90 
91  //put some data here
92  fCCoded[31]=17;
93  }
95  if (pattern_number==2) {
96  if (depth>1) return;
97  if (subdet==4 && etaabs<30) return;
98 
99  if ((etaabs+2)%4!=0) return;
100  int i=(etaabs+2)/4;
101  if (i<1 || i>7) return;
102 
103  if ((phi+3)%4!=0) return;
104  int j=(phi+3)/4;
105  if (j<1 || j>18) return;
106 
107  //add one to BX?
108  if (side<0) fCCoded[phi+10]=i;
109  if (side>0) fCCoded[phi+10]=i+16;
110  }
112  if (pattern_number==3) {
113  if (depth>1 || etaabs!=18 || side!=1 || phi!=32) return;
114  std::cout << "hello" << std::endl;
115  //add one to BX?
116  if (side>0) fCCoded[15]=20;
117  }
118 
119  }
120  catch (...) {return;}
121 }
122 
124  //first fill with pedestal value (currently hard-coded to 0)
125  for (int samples=0; samples<params->m_samples_per_event; samples++) {
126  int index = m_sample_pos + samples;
127  if (index>=SAMPLES) continue;
128 
129  fCCoded [index] = 0;
130  fCQuantized[index] = 0;
131  }
132 
133  //now fill with actual samples
134  for (int samples=0; samples<data->size(); samples++) {
135  int index = m_sample_pos + params->m_presamples_per_event - data->presamples() + samples;
136  if (index<m_sample_pos ||
137  index>=(m_sample_pos+params->m_samples_per_event) ||
138  index>=SAMPLES) continue;
139 
140  fCCoded [index] = data->sample(samples).adc();
141  fCQuantized[index] = data->sample(samples).nominal_fC();
142  }
143 
145 }
146 
148  //first fill with pedestal value (currently hard-coded to 0)
149  for (int samples=0; samples<params->m_samples_per_event; samples++) {
150  int index = m_sample_pos + samples;
151  if (index>=SAMPLES) continue;
152 
153  fCCoded [index] = 0;
154  fCQuantized[index] = 0;
155  }
156 
157  //now fill with actual samples
158  for (int samples=0; samples<data->size(); samples++) {
159  int index = m_sample_pos + params->m_presamples_per_event - data->presamples() + samples;
160  if (index<m_sample_pos ||
161  index>=(m_sample_pos+params->m_samples_per_event) ||
162  index>=SAMPLES) continue;
163 
164  fCCoded [index] = data->sample(samples).adc();
165  fCQuantized[index] = data->sample(samples).nominal_fC();
166  }
167 
169 }
170 
172  //first fill with pedestal value (currently hard-coded to 0)
173  for (int samples=0; samples<params->m_samples_per_event; samples++) {
174  int index = m_sample_pos + samples;
175  if (index>=SAMPLES) continue;
176 
177  fCCoded [index] = 0;
178  fCQuantized[index] = 0;
179  }
180 
181  //now fill with actual samples
182  for (int samples=0; samples<data->size(); samples++) {
183  int index = m_sample_pos + params->m_presamples_per_event - data->presamples() + samples;
184  if (index<m_sample_pos ||
185  index>=(m_sample_pos+params->m_samples_per_event) ||
186  index>=SAMPLES) continue;
187 
188  fCCoded [index] = data->sample(samples).adc();
189  fCQuantized[index] = data->sample(samples).nominal_fC();
190  }
191 
193 }
194 
195 HalfHtrData::HalfHtrData(int crate, int slot, int tb) {
196  for (int i=0; i<24; i++)
197  m_patterns[i].setLoc(crate,slot,tb,i+1);
198  m_crate=crate;
199  m_slot=slot;
200  m_tb=tb;
201  //these are set later with map data
202  m_dcc=0;
203  m_spigot=0;
204 }
205 
206 CrateData::CrateData(int crate, int slotsActive[ChannelPattern::NUM_SLOTS]) {
207  for (int slot=0; slot<ChannelPattern::NUM_SLOTS; slot++) {
208  for (int tb=0;tb<2;tb++) {
209  if (slotsActive[slot]) m_slotsDoubled[slot][tb] = new HalfHtrData(crate,slot,tb);
210  else m_slotsDoubled[slot][tb] = 0;
211  }
212  }
213 }
214 
216  for (int slot=0; slot<ChannelPattern::NUM_SLOTS; slot++) {
217  for (int tb=0;tb<2;tb++) {
218  if (m_slotsDoubled[slot][tb]) delete m_slotsDoubled[slot][tb];
219  }
220  }
221 }
222 
224  if ( slot>=0 && slot<ChannelPattern::NUM_SLOTS && (tb==0 || tb==1) ) return m_slotsDoubled[slot][tb];
225  else return 0;
226 }
227 
229  for (int crate=0; crate<ChannelPattern::NUM_CRATES; crate++) {
230  if (cratesActive[crate]) m_crates[crate] = new CrateData(crate,slotsActive);
231  else m_crates[crate] = 0;
232  }
233 }
234 
236  for (int crate=0; crate<ChannelPattern::NUM_CRATES; crate++) {
237  if (m_crates[crate]) delete m_crates[crate];
238  }
239 }
240 
242  if (crate>=0 && crate<ChannelPattern::NUM_CRATES) return m_crates[crate];
243  else return 0;
244 }
int i
Definition: DBlmapReader.cc:9
void Fill_by_hand(const HcalElectronicsMap *, int)
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:49
HalfHtrData * m_slotsDoubled[ChannelPattern::NUM_SLOTS][2]
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.cc:91
std::vector< HBHEDataFrame >::const_iterator const_iterator
int fCCoded[SAMPLES]
static const int NUM_CRATES
int depth() const
get the tower depth
Definition: HcalDetId.cc:106
void Fill(HtrXmlPatternToolParameters *params, HBHEDigiCollection::const_iterator data)
double fCQuantized[SAMPLES]
static const int SAMPLES
ChannelPattern m_patterns[24]
CrateData(int crate, int slotsActive[ChannelPattern::NUM_SLOTS])
int j
Definition: DBlmapReader.cc:9
static const int NUM_SLOTS
int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.cc:96
int iphi() const
get the cell iphi
Definition: HcalDetId.cc:101
void setHTR(int crate, int slot, int tb)
HalfHtrData(int crate, int slot, int tb)
HalfHtrData * getHalfHtrData(int slot, int one_two_tb)
CrateData * getCrate(int crate)
HtrXmlPatternSet(int cratesActive[ChannelPattern::NUM_CRATES], int slotsActive[ChannelPattern::NUM_SLOTS])
double fCReal[SAMPLES]
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
tuple cout
Definition: gather_cfg.py:145
Readout chain identification for Hcal.
CrateData * m_crates[ChannelPattern::NUM_CRATES]
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id